internal static DateTimeOffset GetCreationTime(string path)
 {
     string str = LongPath.NormalizePath(path);
     new FileIOPermission(FileIOPermissionAccess.Read, new string[] { str }, false, false).Demand();
     string str2 = Path.AddLongPathPrefix(str);
     Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA();
     int errorCode = File.FillAttributeInfo(str2, ref data, false, false);
     if (errorCode != 0)
     {
         __Error.WinIOError(errorCode, str);
     }
     long fileTime = (data.ftCreationTimeHigh << 0x20) | data.ftCreationTimeLow;
     DateTimeOffset offset = new DateTimeOffset(DateTime.FromFileTimeUtc(fileTime).ToLocalTime());
     return offset.ToLocalTime();
 }
        internal static void Delete(string fullPath, string userPath, bool recursive)
        {
            string demandDir = GetDemandDir(fullPath, !recursive);
            new FileIOPermission(FileIOPermissionAccess.Write, new string[] { demandDir }, false, false).Demand();
            Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA();
            int errorCode = File.FillAttributeInfo(fullPath, ref data, false, true);
            switch (errorCode)
            {
                case 0:
                    goto Label_0047;

                case 2:
                    errorCode = 3;
                    break;
            }
            __Error.WinIOError(errorCode, fullPath);
        Label_0047:
            if ((data.fileAttributes & 0x400) != 0)
            {
                recursive = false;
            }
            DeleteHelper(fullPath, userPath, recursive);
        }
Exemple #3
0
        [System.Security.SecurityCritical]  // auto-generated
        internal static bool InternalExists(String path, out int lastError) {
            Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA();
            lastError = File.FillAttributeInfo(path, ref data, false, true);

            return (lastError == 0) && (data.fileAttributes != -1)
                    && ((data.fileAttributes & Win32Native.FILE_ATTRIBUTE_DIRECTORY) != 0);
        }
Exemple #4
0
        [System.Security.SecurityCritical]  // auto-generated
        internal static void Delete(String fullPath, String userPath, bool recursive, bool checkHost)
        {
            String demandPath;
            
            // If not recursive, do permission check only on this directory
            // else check for the whole directory structure rooted below 
            demandPath = GetDemandDir(fullPath, !recursive);
            
#if FEATURE_CORECLR
            if (checkHost) 
            {
                FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Write, userPath, demandPath);
                state.EnsureState();
            }
#else
            // Make sure we have write permission to this directory
            new FileIOPermission(FileIOPermissionAccess.Write, new String[] { demandPath }, false, false ).Demand();
#endif

            // Do not recursively delete through reparse points.  Perhaps in a 
            // future version we will add a new flag to control this behavior, 
            // but for now we're much safer if we err on the conservative side.
            // This applies to symbolic links and mount points.
            Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA();
            int dataInitialised = File.FillAttributeInfo(fullPath, ref data, false, true);
            if (dataInitialised != 0) {
                // Ensure we throw a DirectoryNotFoundException.
                if (dataInitialised == Win32Native.ERROR_FILE_NOT_FOUND)
                    dataInitialised = Win32Native.ERROR_PATH_NOT_FOUND;
                __Error.WinIOError(dataInitialised, fullPath);
            }

            if (((FileAttributes)data.fileAttributes & FileAttributes.ReparsePoint) != 0)
                recursive = false;

            DeleteHelper(fullPath, userPath, recursive, true);
        }
 internal void InitializeFrom(Win32Native.WIN32_FIND_DATA findData)
 {
     _data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA();
     _data.PopulateFrom(findData);
     _dataInitialised = 0;
 }
Exemple #6
0
        // Determine whether path describes an existing directory
        // on disk, avoiding security checks.
        internal static bool InternalExists(String path) {
            Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA();
            int dataInitialised = File.FillAttributeInfo(path,ref data,false);
            if (dataInitialised != 0)
                return false;

            return data.fileAttributes != -1 && (data.fileAttributes & Win32Native.FILE_ATTRIBUTE_DIRECTORY) != 0;
        }
 internal static long GetLength(string path)
 {
     string str = LongPath.NormalizePath(path);
     new FileIOPermission(FileIOPermissionAccess.Read, new string[] { str }, false, false).Demand();
     string str2 = Path.AddLongPathPrefix(str);
     Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA();
     int errorCode = File.FillAttributeInfo(str2, ref data, false, true);
     if (errorCode != 0)
     {
         __Error.WinIOError(errorCode, path);
     }
     if ((data.fileAttributes & 0x10) != 0)
     {
         __Error.WinIOError(2, path);
     }
     return ((data.fileSizeHigh << 0x20) | (data.fileSizeLow & ((long) 0xffffffffL)));
 }
 internal static bool InternalExists(string path)
 {
     Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA();
     return (((FillAttributeInfo(path, ref data, false, true) == 0) && (data.fileAttributes != -1)) && ((data.fileAttributes & 0x10) == 0));
 }
 public static DateTime GetLastWriteTimeUtc(string path)
 {
     string fullPathInternal = Path.GetFullPathInternal(path);
     new FileIOPermission(FileIOPermissionAccess.Read, new string[] { fullPathInternal }, false, false).Demand();
     Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA();
     int errorCode = FillAttributeInfo(fullPathInternal, ref data, false, false);
     if (errorCode != 0)
     {
         __Error.WinIOError(errorCode, fullPathInternal);
     }
     long fileTime = (data.ftLastWriteTimeHigh << 0x20) | data.ftLastWriteTimeLow;
     return DateTime.FromFileTimeUtc(fileTime);
 }
 public static FileAttributes GetAttributes(string path)
 {
     string fullPathInternal = Path.GetFullPathInternal(path);
     new FileIOPermission(FileIOPermissionAccess.Read, new string[] { fullPathInternal }, false, false).Demand();
     Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA();
     int errorCode = FillAttributeInfo(fullPathInternal, ref data, false, true);
     if (errorCode != 0)
     {
         __Error.WinIOError(errorCode, fullPathInternal);
     }
     return (FileAttributes) data.fileAttributes;
 }
Exemple #11
0
         // Called from DirectoryInfo as well.  FullPath is fully qualified,
        // while the user path is used for feedback in exceptions.
        internal static void Delete(String fullPath, String userPath, bool recursive)
        {
            // Do not recursively delete through reparse points.  Perhaps in a 
            // future version we will add a new flag to control this behavior, 
            // but for now we're much safer if we err on the conservative side.
            // This applies to symbolic links and mount points.
            Win32Native.WIN32_FILE_ATTRIBUTE_DATA data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA();
            int dataInitialised = File.FillAttributeInfo(fullPath, ref data, false, true);
            if (dataInitialised != 0) {
                // Ensure we throw a DirectoryNotFoundException.
                if (dataInitialised == Win32Native.ERROR_FILE_NOT_FOUND)
                    dataInitialised = Win32Native.ERROR_PATH_NOT_FOUND;
                __Error.WinIOError(dataInitialised, fullPath);
            }

            if (((FileAttributes)data.fileAttributes & FileAttributes.ReparsePoint) != 0)
                recursive = false;

            DeleteHelper(fullPath, userPath, recursive, true);
        }