/// <include file='Doc/Streams.xml' path='docs/method[@name="Stat"]/*'/> public virtual StatStruct Stat() { if (this.Wrapper != null) { return this.Wrapper.Stat(OpenedPath, StreamStatOptions.Empty, StreamContext.Default, true); } PhpException.Throw(PhpError.Warning, CoreResources.GetString("wrapper_op_unsupported", "Stat")); StatStruct rv = new StatStruct(); rv.st_size = -1; return rv; }
private static void Clear() { statCache = new StatStruct(); statCacheUrl = null; }
/// <summary> /// Creates a <see cref="PhpArray"/> from the <see cref="StatStruct"/> /// copying the structure members into the array. /// </summary> /// <remarks> /// The resulting PhpArray has following associative keys in the given order /// (each has a corresponding numeric index starting from zero). /// As of ordering, first come all the numeric indexes and then come all the associative indexes. /// <list type="table"> /// <item><term>dev</term><term>Drive number of the disk containing the file (same as st_rdev). </term></item> /// <item><term>ino</term><term>Number of the information node (the inode) for the file (UNIX-specific). On UNIX file systems, the inode describes the file date and time stamps, permissions, and content. When files are hard-linked to one another, they share the same inode. The inode, and therefore st_ino, has no meaning in the FAT, HPFS, or NTFS file systems. </term></item> /// <item><term>mode</term><term>Bit mask for file-mode information. The _S_IFDIR bit is set if path specifies a directory; the _S_IFREG bit is set if path specifies an ordinary file or a device. User read/write bits are set according to the file's permission mode; user execute bits are set according to the path extension. </term></item> /// <item><term>nlink</term><term>Always 1 on non-NTFS file systems. </term></item> /// <item><term>uid</term><term>Numeric identifier of user who owns file (UNIX-specific). This field will always be zero on Windows NT systems. A redirected file is classified as a Windows NT file. </term></item> /// <item><term>gid</term><term>Numeric identifier of group that owns file (UNIX-specific) This field will always be zero on Windows NT systems. A redirected file is classified as a Windows NT file. </term></item> /// <item><term>rdev</term><term>Drive number of the disk containing the file (same as st_dev). </term></item> /// <item><term>size</term><term>Size of the file in bytes; a 64-bit integer for _stati64 and _wstati64 </term></item> /// <item><term>atime</term><term>Time of last access of file. Valid on NTFS but not on FAT formatted disk drives. Gives the same </term></item> /// <item><term>mtime</term><term>Time of last modification of file. </term></item> /// <item><term>ctime</term><term>Time of creation of file. Valid on NTFS but not on FAT formatted disk drives. </term></item> /// <item><term>blksize</term><term>Always -1 on non-NTFS file systems. </term></item> /// <item><term>blocks</term><term>Always -1 on non-NTFS file systems. </term></item> /// </list> /// </remarks> /// <param name="stat">A <see cref="StatStruct"/> returned by a stream wrapper.</param> /// <returns>A <see cref="PhpArray"/> in the format of the <c>stat()</c> PHP function.</returns> internal static PhpArray BuildStatArray(StatStruct stat) { // An unitialized StatStruct means an error. if (stat.st_ctime == 0) return null; PhpArray result = new PhpArray(13, 13); result.Add(0, (int)stat.st_dev); // device number result.Add(1, (int)stat.st_ino); // inode number result.Add(2, (int)stat.st_mode); // inode protection mode result.Add(3, (int)stat.st_nlink); // number of links result.Add(4, (int)stat.st_uid); // userid of owner result.Add(5, (int)stat.st_gid); // groupid of owner result.Add(6, (int)stat.st_rdev); // device type, if inode device -1 result.Add(7, (int)stat.st_size); // size in bytes (reset by caller) result.Add(8, unchecked((int)stat.st_atime)); // time of last access (unix timestamp) result.Add(9, unchecked((int)stat.st_mtime)); // time of last modification (unix timestamp) result.Add(10, unchecked((int)stat.st_ctime)); // time of last change (unix timestamp) result.Add(11, (int)-1); // blocksize of filesystem IO (-1) result.Add(12, (int)-1); // number of blocks allocated (-1) result.Add("dev", (int)stat.st_dev); // device number result.Add("ino", (int)stat.st_ino); // inode number result.Add("mode", (int)stat.st_mode); // inode protection mode result.Add("nlink", (int)stat.st_nlink); // number of links result.Add("uid", (int)stat.st_uid); // userid of owner result.Add("gid", (int)stat.st_gid); // groupid of owner result.Add("rdev", (int)stat.st_rdev); // device type, if inode device -1 result.Add("size", (int)stat.st_size); // size in bytes (reset by caller) result.Add("atime", unchecked((int)stat.st_atime)); // time of last access (unix timestamp) result.Add("mtime", unchecked((int)stat.st_mtime)); // time of last modification (unix timestamp) result.Add("ctime", unchecked((int)stat.st_ctime)); // time of last change (unix timestamp) result.Add("blksize", (int)-1); // blocksize of filesystem IO (-1) result.Add("blocks", (int)-1); // number of blocks allocated (-1) return result; }
/// <summary> /// Stat the path coming from ResolvePath (file:// wrapper expects path w/o the scheme). /// </summary> /// <param name="path"></param> /// <param name="url"></param> /// <param name="wrapper"></param> /// <param name="quiet"></param> /// <returns>True if stat was successfuly added into cache.</returns> private static bool StatInternalStat(string path, string url, StreamWrapper wrapper, bool quiet) { StatStruct stat = wrapper.Stat(path, quiet ? StreamStatOptions.Quiet : StreamStatOptions.Empty, StreamContext.Default, false); if (stat.st_size >= 0) { statCacheUrl = url; statCache = stat; return true; } else return false; }