Changes between Version 22 and Version 23 of Docs/Prog/Manual/ApplicationLibraries/lib825ev/File/CFile
- Timestamp:
- 03/12/25 08:05:05 (4 weeks ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Docs/Prog/Manual/ApplicationLibraries/lib825ev/File/CFile
v22 v23 7 7 == Constructors == 8 8 9 {{{ 9 {{{#!c++ 10 10 CFile(void); 11 11 CFile(const string& strFilename); … … 30 30 ==== Examples ==== 31 31 32 {{{ 32 {{{#!c++ 33 33 CFile fileLog("/mnt/fl1/log.txt", "a"); 34 34 if(fileLog.IsOpen()) … … 39 39 }}} 40 40 41 {{{ 41 {{{#!c++ 42 42 CFile fileLog("/mnt/fl1/log.txt"); 43 43 }}} … … 49 49 Opens a specified file, or using the filename already stored in the object. 50 50 51 {{{ 51 {{{#!c++ 52 52 bool Open(const string& strFilename, const string& strMode); 53 53 bool Open(const string& strFilename, const char* pszMode); … … 71 71 ==== Example ==== 72 72 73 {{{ 73 {{{#!c++ 74 74 CFile file; 75 75 if(file.Open("/tmp/tmpfile", "w") == false) … … 82 82 === Close === 83 83 Closes the file 84 {{{ 84 {{{#!c++ 85 85 void Close(void); 86 86 }}} … … 100 100 ==== Example ==== 101 101 102 {{{ 102 {{{#!c++ 103 103 CFile file("/dev/ttyS1", "w"); 104 104 file.Print("This is a test\r\n"); … … 109 109 === SetSerial === 110 110 Set the baud rate, number of data bits, parity, and number of stop bits for serial ports. 111 {{{ 111 {{{#!c++ 112 112 bool SetSerial(baud_index baud, data_bit_index = data8, parity_index = parityNone, stop_bit_index = stopOne); 113 113 }}} … … 127 127 ==== Examples ==== 128 128 129 {{{ 129 {{{#!c++ 130 130 CFile file("/dev/ttyS1", "w"); 131 131 if(file.IsOpen()) … … 135 135 }}} 136 136 137 {{{ 137 {{{#!c++ 138 138 CFile file("/dev/ttyS1", "w"); 139 139 if(file.IsOpen()) … … 145 145 === ReadLine === 146 146 Reads a text file a line at a time. 147 {{{ 147 {{{#!c++ 148 148 bool ReadLine(string& strLine); 149 149 }}} … … 161 161 ==== Example ==== 162 162 163 {{{ 163 {{{#!c++ 164 164 CFile file("/mnt/nand/apps/test/config.txt", "r"); 165 165 if(file.IsOpen()) … … 179 179 === DeleteFile === 180 180 Deletes a file 181 {{{ 181 {{{#!c++ 182 182 static bool DeleteFile(const string& strFilename); 183 183 static bool DeleteFile(const char* pszFilename); … … 198 198 ==== Examples ==== 199 199 200 {{{ 200 {{{#!c++ 201 201 string str = "/tmp/tmpfile"; 202 202 CFile::DeleteFile(str); 203 203 }}} 204 204 205 {{{ 205 {{{#!c++ 206 206 if(CFile::DeleteFile("/tmp/tmpfile") == false) 207 207 { … … 210 210 }}} 211 211 212 {{{ 212 {{{#!c++ 213 213 CFile file("/tmp/tmpfile", "w"); 214 214 if(file.IsOpen()) … … 223 223 === IsOpen === 224 224 Check whether the file is open 225 {{{ 225 {{{#!c++ 226 226 bool IsOpen(void) 227 227 }}} … … 238 238 ==== Example ==== 239 239 240 {{{ 240 {{{#!c++ 241 241 CFile file("/tmp/tmpfile", "w"); 242 242 if(file.IsOpen() == false) … … 248 248 === IsReady === 249 249 Check the state of the serial CTS input 250 {{{ 250 {{{#!c++ 251 251 bool IsReady(void); 252 252 }}} … … 265 265 ==== Example ==== 266 266 267 {{{ 267 {{{#!c++ 268 268 CFile fileLogOutput("/dev/ttyS1", "w"); 269 269 if(fileLogOutput.IsOpen()) … … 281 281 Set the state of the serial RTS output 282 282 283 {{{ 283 {{{#!c++ 284 284 bool SetRTS(bool bRTSOn = true); 285 285 }}} … … 297 297 ==== Example ==== 298 298 299 {{{ 299 {{{#!c++ 300 300 CFile fileLogOutput("/dev/ttyS1", "w"); 301 301 fileLogOutput.SetRTS(true); … … 307 307 Get the file handle of the member FILE. 308 308 309 {{{ 309 {{{#!c++ 310 310 FILE* GetFile(void); 311 311 }}} … … 320 320 ==== Example ==== 321 321 322 {{{ 322 {{{#!c++ 323 323 CFile file("/tmp/test", "w"); 324 324 if(file.IsOpen()) … … 332 332 === Print === 333 333 Outputs text which may include format specifiers. For each format specifier an additional parameter must be provided. 334 {{{ 334 {{{#!c++ 335 335 void Print(const string& strFormat, ...); 336 336 void Print(const char* pszFormat, ...); … … 353 353 354 354 ==== Examples ==== 355 {{{ 355 {{{#!c++ 356 356 string str = "Hello World\r\n"; 357 357 file.Print(str); 358 358 }}} 359 359 360 {{{ 360 {{{#!c++ 361 361 int n = 5; 362 362 string str = "ABC"; … … 364 364 }}} 365 365 366 {{{ 366 {{{#!c++ 367 367 // This is a function to log update data to two devices 368 368 // g_fileLog1, and g_fileLog2 are globals that should already have been opened before this function is called. … … 382 382 === SetNonBlocking === 383 383 Set the file to not wait for data to arrive when reading. 384 {{{ 384 {{{#!c++ 385 385 void SetNonBlocking(void); 386 386 }}} … … 400 400 ==== Example ==== 401 401 402 {{{ 402 {{{#!c++ 403 403 CFile fileComm("/dev/ttyS0", "r"); 404 404 if(fileComm.IsOpen()) … … 411 411 === Read === 412 412 Reads a binary block of data from a file. 413 {{{ 413 {{{#!c++ 414 414 bool Read(void *pData, size_t nSize); 415 415 }}} … … 430 430 === Write === 431 431 Writes a binary block of data to a file. 432 {{{ 432 {{{#!c++ 433 433 bool Write(void *pData, size_t nSize); 434 434 }}} … … 448 448 === GetBytesRead === 449 449 Returns how may bytes were read from previous Read function. 450 {{{ 450 {{{#!c++ 451 451 size_t GetBytesRead(void); 452 452 }}} … … 465 465 Returns how may bytes were written from previous Write function. 466 466 467 {{{ 467 {{{#!c++ 468 468 size_t GetBytesWritten(void); 469 469 }}} … … 481 481 === Seek === 482 482 483 {{{ 483 {{{#!c++ 484 484 bool Seek(long int offset, long int origin = SEEK_SET); 485 485 }}}