GetErrorCode() static private method

static private GetErrorCode ( System ioe ) : int
ioe System
return int
Exemplo n.º 1
0
        public IDisposable Acquire()
        {
            string dir = Path.GetDirectoryName(filepath);

            lock (this)
            {
#if !WindowsCE && !SILVERLIGHT
                while (stream != null)
                {
                    Monitor.Wait(this);
                }
#endif

                while (true)
                {
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }
                    try
                    {
                        Debug.Assert(stream == null, "Stream was not null--programmer error");
                        stream = new FileStream(filepath, FileMode.OpenOrCreate, FileAccess.Read, FileShare.None);
                        return(disposeHelper);
                    }
                    catch (IOException ioe)
                    {
                        int errorCode = SafeNativeMethods.GetErrorCode(ioe);
                        switch (errorCode)
                        {
                        case 32:
                        case 33:
                        case 32 | 0x1620:
                        case 33 | 0x1620:
                            Thread.Sleep(50);
                            continue;

                        default:
                            throw;
                        }
                    }
                }
            }
        }