fork/gdu
git clone https://git.julia.blue/fork/gdu
4596b8f
master
1//go:build windows || plan9 2 3package analyze 4 5import ( 6"os" 7"syscall" 8"time" 9) 10 11func getPlatformSpecificUsageAndMli (info os.FileInfo ) (usage int64 ,ino uint64 ) { 12return info .Size (),0 // No block info on Windows, use apparent size 13} 14 15func setPlatformSpecificAttrs (file * File ,f os.FileInfo ) { 16stat := f .Sys ().(* syscall.Win32FileAttributeData ) 17file .Mtime = time .Unix (0 ,stat .LastWriteTime .Nanoseconds ()) 18file .Usage = f .Size ()// No block info on Windows, use apparent size 19 20// Checking to see if this file is an "online only" OneDrive file, as they don't take any disk space. 21// https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants 22const fileAttributeRecallOnOpen = 0x100000 23const fileAttributeRecallOnDataAccess = 0x400000 24if data ,ok := f .Sys ().(* syscall.Win32FileAttributeData );ok { 25if data .FileAttributes & (fileAttributeRecallOnOpen | fileAttributeRecallOnDataAccess )!= 0 { 26file .Size = 0 27 } 28 } 29} 30 31func setDirPlatformSpecificAttrs (dir * Dir ,path string ) { 32stat ,err := os .Stat (path ) 33if err != nil { 34return 35 } 36dir .Mtime = stat .ModTime () 37} 38 39// getSyscallStats extracts usage and inode info from os.FileInfo using syscall 40func getSyscallStats (info os.FileInfo ) (usage int64 ,mli uint64 ) { 41usage = info .Size () 42return 43}