Esempio n. 1
0
        /// <summary>
        /// Gets the size, in bytes, of the current file.
        /// Unlike <see cref="FileInfo.Length"/>, this method follows symbolic links.
        /// </summary>
        /// <param name="this">The <see cref="FileInfo"/> representing the current file.</param>
        /// <returns>The size of the file in bytes, or -1 if the file does not exist or is a directory.</returns>
        /// <exception cref="IOException"></exception>
        public static long Length(this FileInfo @this)
        {
            var dirEntry = @this.AsDirEntry();

            return(dirEntry.FileType == Emet.FileSystems.FileType.File ?
                   dirEntry.FileSize : -1);
        }
Esempio n. 2
0
 /// <summary>
 /// Gets a value indicating whether the specified file exists.
 /// Unlike <see cref="FileInfo.Exists"/>, this method follows symbolic links.
 /// </summary>
 /// <param name="this">The <see cref="FileInfo"/> representing the current file.</param>
 /// <returns><see langword="true"/> if the file exists on disk and is accessible, <see langword="false"/> otherwise.</returns>
 internal static bool ContentExists(this FileInfo @this)
 {
     return(@this.AsDirEntry().FileType == Emet.FileSystems.FileType.File);
 }