Exemplo n.º 1
0
            public override void close(CodeContext /*!*/ context)
            {
                if (_closed)
                {
                    return;
                }

                flush(context);
                _closed = true;
                _readStream.Close();
                _readStream.Dispose();
                if (!object.ReferenceEquals(_readStream, _writeStream))
                {
                    _writeStream.Close();
                    _writeStream.Dispose();
                }


                PythonFileManager myManager = _context.RawFileManager;

                if (myManager != null)
                {
                    myManager.Remove(this);
                }
            }
Exemplo n.º 2
0
        public static object Open(ICallerContext context, string filename, int flag, int mode)
        {
            FileStream fs = File.Open(filename, FileModeFromFlags(flag), FileAccessFromFlags(flag));
            PythonFile pf = PythonFile.Make(context, null, fs);

            return(PythonFileManager.GetIdFromFile(pf));
        }
Exemplo n.º 3
0
            public override void close(CodeContext /*!*/ context)
            {
                if (_closed)
                {
                    return;
                }

                try {
                    flush(context);
                } catch (IOException) {
                    // flushing can fail, esp. if the other half of a pipe is closed
                    // ignore it because we're closing anyway
                }
                _closed = true;

                if (_closefd)
                {
                    if (_readStream != null)
                    {
                        _readStream.Close();
                        _readStream.Dispose();
                    }
                    if (_writeStream != null && !ReferenceEquals(_readStream, _writeStream))
                    {
                        _writeStream.Close();
                        _writeStream.Dispose();
                    }

                    PythonFileManager myManager = _context.RawFileManager;
                    myManager?.Remove(this);
                }
            }
Exemplo n.º 4
0
        public static object GetFileFStats(int fd)
        {
            PythonFile pf = PythonFileManager.GetFileFromId(fd);

            return(GetFileStats(pf.name));
        }
Exemplo n.º 5
0
        public static object FileForDescriptor(ICallerContext context, int fd, string mode, int bufsize)
        {
            PythonFile pf = PythonFileManager.GetFileFromId(fd);

            return(pf);
        }
Exemplo n.º 6
0
        public static void WriteToFileDescriptor(int fd, string text)
        {
            PythonFile pf = PythonFileManager.GetFileFromId(fd);

            pf.Write(text);
        }
Exemplo n.º 7
0
        public static void CloseFileDescriptor(int fd)
        {
            PythonFile pf = PythonFileManager.GetFileFromId(fd);

            pf.Close();
        }
Exemplo n.º 8
0
        public static string ReadFromFileDescriptor(int fd, int buffersize)
        {
            PythonFile pf = PythonFileManager.GetFileFromId(fd);

            return(pf.Read());
        }