Package cli.System.IO

Examples of cli.System.IO.FileStream


            throw new SyncFailedException(x.getMessage());
        }

        if (stream instanceof FileStream)
        {
            FileStream fs = (FileStream)stream;
            boolean ok = ikvm.internal.Util.WINDOWS ? flushWin32(fs) : flushPosix(fs);
            if (!ok)
            {
                throw new SyncFailedException("sync failed");
            }
View Full Code Here


    // Grabs a file lock
    @cli.System.Security.SecuritySafeCriticalAttribute.Annotation
    static int lock0(FileDescriptor fd, boolean blocking, long pos, long size, boolean shared) throws IOException
    {
        FileStream fs = (FileStream)fd.getStream();
        if (winNT)
        {
            int LOCKFILE_FAIL_IMMEDIATELY = 1;
            int LOCKFILE_EXCLUSIVE_LOCK = 2;
            int ERROR_LOCK_VIOLATION = 33;
            int flags = 0;
            OVERLAPPED o = new OVERLAPPED();
            o.OffsetLow = (int)pos;
            o.OffsetHigh = (int)(pos >> 32);
            if (!blocking)
            {
                flags |= LOCKFILE_FAIL_IMMEDIATELY;
            }
            if (!shared)
            {
                flags |= LOCKFILE_EXCLUSIVE_LOCK;
            }
            int result = LockFileEx(fs.get_SafeFileHandle(), flags, 0, (int)size, (int)(size >> 32), o);
            if (result == 0)
            {
                int error = cli.System.Runtime.InteropServices.Marshal.GetLastWin32Error();
                if (!blocking && error == ERROR_LOCK_VIOLATION)
                {
                    return NO_LOCK;
                }
                throw new IOException("Lock failed");
            }
            return LOCKED;
        }
        else
        {
            try
            {
                if (false) throw new cli.System.ArgumentOutOfRangeException();
                for (;;)
                {
                    try
                    {
                        if (false) throw new cli.System.IO.IOException();
                        if (false) throw new cli.System.ObjectDisposedException("");
                        fs.Lock(pos, size);
                        return shared ? RET_EX_LOCK : LOCKED;
                    }
                    catch (cli.System.IO.IOException x)
                    {
                        if (!blocking)
View Full Code Here

    // Releases a file lock
    @cli.System.Security.SecuritySafeCriticalAttribute.Annotation
    static void release0(FileDescriptor fd, long pos, long size) throws IOException
    {
        FileStream fs = (FileStream)fd.getStream();
        if (winNT)
        {
            OVERLAPPED o = new OVERLAPPED();
            o.OffsetLow = (int)pos;
            o.OffsetHigh = (int)(pos >> 32);
            int result = UnlockFileEx(fs.get_SafeFileHandle(), 0, (int)size, (int)(size >> 32), o);
            if (result == 0)
            {
                throw new IOException("Release failed");
            }
        }
        else
        {
            try
            {
                if (false) throw new cli.System.ArgumentOutOfRangeException();
                if (false) throw new cli.System.IO.IOException();
                if (false) throw new cli.System.ObjectDisposedException("");
                fs.Unlock(pos, size);
            }
            catch (cli.System.ArgumentOutOfRangeException x)
            {
                throw new IOException(x.getMessage());
            }
View Full Code Here

    }

    // Creates a new mapping
    private long map0(int prot, long position, long length) throws IOException
    {
        FileStream fs = (FileStream)fd.getStream();
        if (win32)
            return mapViewOfFileWin32(fs, prot, position, length);
        else
            return mapViewOfFilePosix(fs, prot, position, length);
    }
View Full Code Here

TOP

Related Classes of cli.System.IO.FileStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.