Skip to content

Commit

Permalink
Provide proper create/modify/access timestamps for special FAT-32 dir…
Browse files Browse the repository at this point in the history
…ectory entries ("." and "..").
  • Loading branch information
Max Gotlib committed May 2, 2024
1 parent 7e52208 commit 976a35b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions filesystem/fat32/fat32.go
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,7 @@ func (fs *FileSystem) readDirWithMkdir(p string, doMake bool) (*Directory, []*di
if err != nil {
return nil, nil, fmt.Errorf("failed to create subdirectory %s", "/"+strings.Join(paths[0:i+1], "/"))
}
currentDir.modifyTime = subdirEntry.createTime
// make a basic entry for the new subdir
parentDirectoryCluster := currentDir.clusterLocation
if parentDirectoryCluster == 2 {
Expand All @@ -859,8 +860,22 @@ func (fs *FileSystem) readDirWithMkdir(p string, doMake bool) (*Directory, []*di
dir := &Directory{
directoryEntry: directoryEntry{clusterLocation: subdirEntry.clusterLocation},
entries: []*directoryEntry{
{filenameShort: ".", isSubdirectory: true, clusterLocation: subdirEntry.clusterLocation},
{filenameShort: "..", isSubdirectory: true, clusterLocation: parentDirectoryCluster},
{
filenameShort: ".",
isSubdirectory: true,
clusterLocation: subdirEntry.clusterLocation,
createTime: subdirEntry.createTime,
modifyTime: subdirEntry.modifyTime,
accessTime: subdirEntry.accessTime,
},
{
filenameShort: "..",
isSubdirectory: true,
clusterLocation: parentDirectoryCluster,
createTime: currentDir.createTime,
modifyTime: currentDir.modifyTime,
accessTime: currentDir.accessTime,
},
},
}
// write the new directory entries to disk
Expand Down

0 comments on commit 976a35b

Please sign in to comment.