Open stevstrong opened 3 years ago
I lifted new definitions for file system structures from various places since exFAT has a totally different structures than FAT, I needed unique symbols for both and I wanted to allow for future use on processors with various endian and alignment requirements.
The new symbols are here. Notice that all definitions are in terms of uint8_t bytes, not packed structs.
There can be no function like readDir() for FsFile with both FAT16/FAT32 and exFAT.
I am trying to add functions to get more properties of files to FsFile. More new functions are in SdFat-beta in FsFile.h.
uint64_t fileSize();
bool getAccessDateTime(uint16_t* pdate, uint16_t* ptime);
bool getCreateDateTime(uint16_t* pdate, uint16_t* ptime);
bool getModifyDateTime(uint16_t* pdate, uint16_t* ptime)
bool isContiguous();
bool isDir();
bool isFile();
bool isHidden();
bool isReadOnly();
I am still changing date/time functions. The definitions are in FsDateTime.h these formatting functions will change.
Thanks a lot for the reply, I will have a look on those functions.
I want to use readDir()
so I changed FsFile
instance to FatFile
and it worked.
I will come back after I finished the replacement of all other functions/symbols, so please keep this open till then.
While looking for a replacement for isDir(&dir)
I have found isFileDir(&dir)
in FsStructs.h
. Is that the correct replacement?
I am not sure because the name isFileDir(&dir)
could mean (isFile or isDir)(dir).
Or this name was selected just to differentiate from file.isDir()
.
Don't know where isFileDir came from, I don't use it. I copied the stuff in FsStructs.h from various sources that reverse engineered FAT, exFAT and other file systems.
I should warn you that anything you use in FsStructs.h to interpret a directory entry may go away or change at any time. It is not in the documentation for supported functions/symbols.
You can use the Microsoft spec for FAT to define your own symbols:
https://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/fatgen103.doc
I will probably mark readDir(DirFat_t* dir) as deprecated since it is specific to FAT and I don't use it. It was a mistake I made 10 years ago before I added functions for file attributes.
Just open a directory and call read but don't expect support.
read(dir, sizeof(DirFat_t));
I provided openNext() as the supported way to open all files in a directory and get their properties.
Here are the supported attribute functions for an open FAT16/FAT32 file.
/** \return True if this is a directory. */
bool isDir() const
/** \return True if this is a normal file. */
bool isFile() const
/** \return True if this is a hidden file. */
bool isHidden() const
/** \return true if this file has a Long File Name. */
bool isLFN() const
/** \return True if this is an open file/directory. */
bool isOpen() const
/** \return True file is readable. */
bool isReadable() const
/** \return True if file is read-only */
bool isReadOnly() const
/** \return True if this is the root directory. */
bool isRoot() const
/** \return True if this is the FAT32 root directory. */
bool isRoot32() const
/** \return True if this is the FAT12 of FAT16 root directory. */
bool isRootFixed() const
/** \return True if this is a subdirectory. */
bool isSubDir() const
/** \return True if this is a system file. */
bool isSystem() const
/** \return True file is writable. */
bool isWritable() const
Eventually attributes common to FAT and exFAT will be supported for FsFile.
Hi, after updating to v.2.x I have said error message when trying to compile the code which was ok for v1.x. I can see that
readDir()
is member of FatFile, but not in FsFile: https://github.com/greiman/SdFat/blob/cb5a7d2afb4eb94f2563044645fc816f0ea4c2c8/src/FatLib/FatFile.cpp#L834 I was implementing a directory listing with detailed information based on the lsPrintNext function from the old SdFile.cpp:There are several other related error messages as well, like:
error: 'DIR_NAME_FREE' was not declared in this scope
error: 'DIR_NAME_DELETED' was not declared in this scope
error: 'DIR_IS_SUBDIR' was not declared in this scope
- found alternative:isDir()
error: 'DIR_IS_FILE_OR_SUBDIR' was not declared in this scope
- found alternative:isFileOrSubdir(dir)
error: 'struct DirFat_t' has no member named 'lastWriteDate'
error: 'struct DirFat_t' has no member named 'lastWriteTime'
error: 'FAT_MINUTE' was not declared in this scope
error: 'FAT_YEAR' was not declared in this scope
error: 'FAT_DAY' was not declared in this scope
error: 'FAT_SECOND' was not declared in this scope
Can you please suggest alternatives for these expressions? Or eventually an alternative way how can I implement the same functionality with v2.x? The old method yield the following result: I appreciate any advice, thank you in advance.