Exemplo n.º 1
0
 internal void InitializeFrom(Win32Native.WIN32_FIND_DATA findData)
 {
     _data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA();
     _data.PopulateFrom(findData);
     _dataInitialised = 0;
 }
Exemplo n.º 2
0
        internal static int FillAttributeInfo(string path, ref Win32Native.WIN32_FILE_ATTRIBUTE_DATA data, bool tryagain, bool returnErrorOnNotFound)
        {
            int num = 0;

            if (tryagain)
            {
                Win32Native.WIN32_FIND_DATA win_find_data = new Win32Native.WIN32_FIND_DATA();
                string fileName = path.TrimEnd(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar });
                int    num2     = Win32Native.SetErrorMode(1);
                try
                {
                    bool           flag   = false;
                    SafeFindHandle handle = Win32Native.FindFirstFile(fileName, win_find_data);
                    try
                    {
                        if (handle.IsInvalid)
                        {
                            flag = true;
                            num  = Marshal.GetLastWin32Error();
                            if ((((num == 2) || (num == 3)) || (num == 0x15)) && !returnErrorOnNotFound)
                            {
                                num = 0;
                                data.fileAttributes = -1;
                            }
                            return(num);
                        }
                    }
                    finally
                    {
                        try
                        {
                            handle.Close();
                        }
                        catch
                        {
                            if (!flag)
                            {
                                __Error.WinIOError();
                            }
                        }
                    }
                }
                finally
                {
                    Win32Native.SetErrorMode(num2);
                }
                data.PopulateFrom(win_find_data);
                return(num);
            }
            bool flag2   = false;
            int  newMode = Win32Native.SetErrorMode(1);

            try
            {
                flag2 = Win32Native.GetFileAttributesEx(path, 0, ref data);
            }
            finally
            {
                Win32Native.SetErrorMode(newMode);
            }
            if (!flag2)
            {
                num = Marshal.GetLastWin32Error();
                if (((num != 2) && (num != 3)) && (num != 0x15))
                {
                    return(FillAttributeInfo(path, ref data, true, returnErrorOnNotFound));
                }
                if (!returnErrorOnNotFound)
                {
                    num = 0;
                    data.fileAttributes = -1;
                }
            }
            return(num);
        }