Pchp.Library.Streams.FileStreamWrapper.BuildStatStruct C# (CSharp) Method

BuildStatStruct() static private method

Creates a StatStruct from the StatStruct filling the common members (for files and directories) from the given FileSystemInfo class. The size member (numeric index 7) may be filled by the caller for when info is a FileInfo.
According to these outputs (PHP Win32): fstat(somefile.txt): [dev] => 0 [ino] => 0 [mode] => 33206 [nlink] => 1 [uid] => 0 [gid] => 0 [rdev] => 0 [size] => 24 [atime] => 1091131360 [mtime] => 1091051699 [ctime] => 1091051677 [blksize] => -1 [blocks] => -1 stat(somefile.txt): [dev] => 2 [ino] => 0 [mode] => 33206 // 0100666 [nlink] => 1 [uid] => 0 [gid] => 0 [rdev] => 2 [size] => 24 [atime] => 1091129621 [mtime] => 1091051699 [ctime] => 1091051677 [blksize] => -1 [blocks] => -1 stat(somedir): [st_dev] => 2 [st_ino] => 0 [st_mode] => 16895 // 040777 [st_nlink] => 1 [st_uid] => 0 [st_gid] => 0 [st_rdev] => 2 [st_size] => 0 [st_atime] => 1091109319 [st_mtime] => 1091044521 [st_ctime] => 1091044521 [st_blksize] => -1 [st_blocks] => -1
static private BuildStatStruct ( FileSystemInfo info, FileAttributes attributes, string path ) : StatStruct
info System.IO.FileSystemInfo A or /// of the stat()ed filesystem entry.
attributes FileAttributes The file or directory attributes.
path string The path to the file / directory.
return StatStruct
        internal static StatStruct BuildStatStruct(FileSystemInfo info, FileAttributes attributes, string path)
        {
            StatStruct result;//  = new StatStruct();
            uint device = unchecked((uint)(char.ToLower(info.FullName[0]) - 'a')); // index of the disk

            ushort mode = (ushort)BuildMode(info, attributes, path);

            long atime, mtime, ctime;
            atime = ToStatUnixTimeStamp(info, (_info) => _info.LastAccessTimeUtc);
            mtime = ToStatUnixTimeStamp(info, (_info) => _info.LastWriteTimeUtc);
            ctime = ToStatUnixTimeStamp(info, (_info) => _info.CreationTimeUtc);

            result.st_dev = device;         // device number 
            result.st_ino = 0;              // inode number 
            result.st_mode = mode;          // inode protection mode 
            result.st_nlink = 1;            // number of links 
            result.st_uid = 0;              // userid of owner 
            result.st_gid = 0;              // groupid of owner 
            result.st_rdev = device;        // device type, if inode device -1
            result.st_size = 0;             // size in bytes

            FileInfo file_info = info as FileInfo;
            if (file_info != null)
            {
                result.st_size = file_info.Length;
            }

            result.st_atime = atime;        // time of last access (unix timestamp) 
            result.st_mtime = mtime;        // time of last modification (unix timestamp) 
            result.st_ctime = ctime;        // time of last change (unix timestamp) 
                                            //result.st_blksize = -1;   // blocksize of filesystem IO (-1)
                                            //result.st_blocks = -1;    // number of blocks allocated  (-1)

            return result;
        }