MCGalaxy icon indicating copy to clipboard operation
MCGalaxy copied to clipboard

Created time doesn't work on Unix

Open rdebath opened this issue 2 years ago • 1 comments

The created time doesn't exist on standard Unix filesystems, there's

  • mtime: Lastmodified time
  • atime: Last accessed time
  • ctime: Last metadata change time.

The EXT4 filesystem does have a file created time, but it can only be accessed by the superuser.

A file created time is available on Windows, but this is still technically inaccurate as it doesn't say when the level was created, just when the file was last copied.

Please add a new field to the level properties to be populated when a level is created and suppress the display of the (wrong) time when the property doesn't exist or has a "null" value.

[09:37:26] About test3: Width=128 Height=128 Length=128
[09:37:26]   Physics are OFF, gun usage is disabled
[09:37:26]   Created 20m ago, last backup (24m ago): 14
[09:37:26]   BlockDB (Used for /b) is Enabled with 96468741 entries
[09:37:26]   Visitable by Guest+
[09:37:26]   Modifiable by Guest+
[09:37:26] Use /mi env test3 to see environment settings.

Finding the file created time on an EXT4 filesystem using debugfs and sudo.

xstat() {
  for target in "${@}"; do
    inode=$(ls -di "${target}" | cut -d ' ' -f 1)
    fs=$(df "${target}"  | tail -1 | awk '{print $1}')
    crtime=$(sudo debugfs -R 'stat <'"${inode}"'>' "${fs}" 2>/dev/null | 
    grep -oP 'crtime.*--\s*\K.*')
    printf "%s\t%s\n" "${crtime}" "${target}"
  done
}

rdebath avatar Feb 06 '22 09:02 rdebath

Adding creation date to level properties file has been on private todo list for a while now (over four years), just haven't gotten around to implementing

UnknownShadow200 avatar Feb 07 '22 13:02 UnknownShadow200