fatfs-wasm / Exports / FatFsFile
FatFs file object
• new FatFsFile(filePtr
, exports
, context
)
Name | Type |
---|---|
filePtr |
number |
exports |
FatFsExports |
context |
FatFsMemoryContext |
• Private
#context: FatFsMemoryContext
• Private
#exports: FatFsExports
• Private
#filePtr: number
• get
fp(): number
Low level pointer to the file descriptor
number
▸ close(): void
The f_close function closes an open file and destroys the file object.
void
▸ eof(fp
): number
The f_eof function tests for end-of-file on a file.
Name | Type |
---|---|
fp |
FatFsFile |
number
The f_eof function returns a non-zero value if the read/write pointer has reached end of the file; otherwise it returns a zero.
▸ error(fp
): number
The f_error tests for an error on a file.
Name | Type |
---|---|
fp |
FatFsFile |
number
Returns a non-zero value if a hard error has occured; otherwise it returns a zero.
▸ expand(fsz
, opt
): void
The f_expand function prepares or allocates a contiguous data area to the file.
Name | Type | Description |
---|---|---|
fsz |
number |
Number of bytes in size to prepare or allocate for the file. The data type FSIZE_t is an alias of either DWORD(32-bit) or QWORD(64-bit) depends on the configuration option FF_FS_EXFAT. |
opt |
number |
Allocation mode. Prepare to allocate (0) or Allocate now (1). |
void
▸ gets(maxSize
): string
The f_gets reads a string from the file.
Name | Type |
---|---|
maxSize |
number |
string
the string
▸ lseek(ofs
): void
The f_lseek function moves the file read/write pointer of an open file object. It can also be used to expand the file size (cluster pre-allocation).
Name | Type | Description |
---|---|---|
ofs |
number |
Byte offset from top of the file to set read/write pointer. The data type FSIZE_t is an alias of either DWORD(32-bit) or QWORD(64-bit) depends on the configuration option FF_FS_EXFAT. |
void
▸ putc(chr
): number
The f_putc function puts a character to the file.
Name | Type | Description |
---|---|---|
chr |
number |
A code unit to write. |
number
When the character was written successfuly, it returns number of character encoding units written to the file. When the function failed due to disk full or any error, a negative value will be returned.
▸ puts(str
): number
The f_puts function writes a string to the file.
Name | Type | Description |
---|---|---|
str |
string |
Pointer to the null terminated string to be written. The terminator character will not be written. |
number
When the string was written successfuly, it returns number of character encoding units written to the file. When the function failed due to disk full or any error, a negative value will be returned.
▸ read(buff
, btr?
): number
The f_read function reads data from a file.
Name | Type | Description |
---|---|---|
buff |
Uint8Array |
Pointer to the buffer to store the read data. |
btr? |
number |
Number of bytes to read in range of UINT type. If the file needs to be read fast, it should be read in large chunk as possible. |
number
number of bytes read
▸ rewind(): void
void
▸ size(): number
The f_size function gets the size of a file.
number
Returns the size of the file in unit of byte.
▸ sync(): void
The f_sync function flushes the cached information of a writing file.
void
▸ tell(): number
The f_tell function gets the current read/write pointer of a file.
number
Returns current read/write pointer of the file.
▸ truncate(): void
The f_truncate function truncates the file size to the current file read/write pointer.
void
▸ write(buff
, btw?
): number
The f_write writes data to a file.
Name | Type | Description |
---|---|---|
buff |
Uint8Array |
Pointer to the data to be written. |
btw? |
number |
Specifies number of bytes to write in range of UINT type. If the data needs to be written fast, it should be written in large chunk as possible. |
number
number of bytes written