mirror of
https://github.com/wiiu-env/libfat.git
synced 2024-11-25 19:36:52 +01:00
Truncated files are modified upon opening
This commit is contained in:
parent
2a239bcd2b
commit
145e2cc9d3
@ -111,6 +111,9 @@ int _FAT_open_r (struct _reent *r, void *fileStruct, const char *path, int flags
|
||||
return -1;
|
||||
}
|
||||
|
||||
// We haven't modified the file yet
|
||||
file->modified = false;
|
||||
|
||||
// If the file doesn't exist, create it if we're allowed to
|
||||
if (!fileExists) {
|
||||
if (flags & O_CREAT) {
|
||||
@ -154,6 +157,9 @@ int _FAT_open_r (struct _reent *r, void *fileStruct, const char *path, int flags
|
||||
r->_errno = ENOSPC;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// File entry is modified
|
||||
file->modified = true;
|
||||
} else {
|
||||
// file doesn't exist, and we aren't creating it
|
||||
_FAT_unlock(&partition->lock);
|
||||
@ -189,6 +195,8 @@ int _FAT_open_r (struct _reent *r, void *fileStruct, const char *path, int flags
|
||||
_FAT_fat_clearLinks (partition, file->startCluster);
|
||||
file->startCluster = CLUSTER_FREE;
|
||||
file->filesize = 0;
|
||||
// File is modified since we just cut it all off
|
||||
file->modified = true;
|
||||
}
|
||||
|
||||
// Remember the position of this file's directory entry
|
||||
@ -221,8 +229,6 @@ int _FAT_open_r (struct _reent *r, void *fileStruct, const char *path, int flags
|
||||
file->appendPosition = file->rwPosition;
|
||||
}
|
||||
|
||||
file->modified = false;
|
||||
|
||||
file->inUse = true;
|
||||
|
||||
// Insert this file into the double-linked list of open files
|
||||
|
Loading…
Reference in New Issue
Block a user