示例#1
0
 public FileStream(File file, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.IO.FileOptions options, int bufferSize, object creator)
     : base(file.ToString(), mode, access, share, bufferSize, options)
 {
     _file = file;
     _mode = mode;
     _access = access;
     _share = share;
     _options = options;
     _bufferSize = bufferSize;
     _creator = creator;
     _createdTimestamp = System.DateTime.Now;
     // Gets the calling method and stores it in _lastAccess - this is used to help resolve concurrent access request issues.
     _lastAccess = new StackTrace(true).GetFrame(1);
     FileSystem.Instance.RegisterHandle(this);
 }
示例#2
0
 public XNetworkStream(Socket socket, System.IO.FileAccess access, bool ownsSocket)
     : base(socket, access, ownsSocket)
 {
 }
示例#3
0
 public void StreamDataName(KSoft.IO.XmlElementStream s, FA mode, ref string name)
 {
     BCollectionXmlParams.StreamValue(s, mode, DataName, ref name,
                                      UseInnerTextForData, UseElementForData, InternDataNames,
                                      ToLowerDataNames);
 }
示例#4
0
 public override void StreamXml(KSoft.IO.XmlElementStream s, FA mode, XML.BXmlSerializerInterface xs)
 {
     s.StreamAttributeOpt(mode, kXmlAttrAttackRating, ref m_attackRating, Util.kNotFalsePredicate);
     s.StreamAttributeOpt(mode, kXmlAttrBaseType, ref m_baseType, Util.kNotFalsePredicate);
     s.StreamAttributeOpt(mode, kXmlAttrShielded, ref m_shielded, Util.kNotFalsePredicate);
 }
示例#5
0
 public void StreamXml(KSoft.IO.XmlElementStream s, FA mode, XML.BXmlSerializerInterface xs)
 {
     s.StreamElementOpt(mode, null, ref mXmlVersion, Util.kNotInvalidPredicate);
     SkullManager.StreamXml(s, mode, xs);
 }
示例#6
0
 public NetworkStream(System.Net.Sockets.Socket socket, System.IO.FileAccess access, bool ownsSocket)
 {
 }
示例#7
0
 public Descriptor(FSInputStream enclosingInstance, System.IO.FileInfo file, System.IO.FileAccess fileAccess)
     : base(new System.IO.FileStream(file.FullName, System.IO.FileMode.Open, fileAccess, System.IO.FileShare.ReadWrite))
 {
 }
示例#8
0
 public SqlFileStream(string path, byte[] transactionContext, System.IO.FileAccess access, System.IO.FileOptions options, Int64 allocationSize)
 {
 }
示例#9
0
 public Descriptor(FSIndexInput enclosingInstance, System.IO.FileInfo file, System.IO.FileAccess mode)
     : base(new System.IO.FileStream(file.FullName, System.IO.FileMode.Open, mode, System.IO.FileShare.ReadWrite))
 {
     InitBlock(enclosingInstance);
 }
示例#10
0
        public FileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access)
        {
            ThrowHelper.ThrowIfNull(path);

            if ((int)access < 1 || (int)access > 3)
            {
                throw new System.ArgumentOutOfRangeException();
            }

            switch (mode)
            {
            case System.IO.FileMode.CreateNew:      CreateIfNotExist(); break;

            case System.IO.FileMode.Create:         CreateOrTruncate(); break;

            case System.IO.FileMode.Open:           OpenExisting();     break;

            case System.IO.FileMode.OpenOrCreate:   OpenOrCreate();     break;

            case System.IO.FileMode.Truncate:       TruncateExisting(); break;

            case System.IO.FileMode.Append:         AppendOrCreate();   break;

            default:           throw new System.ArgumentOutOfRangeException();
            }

            void CreateIfNotExist()
            {
                // create a new file; throw IOException if exists
                if (access == System.IO.FileAccess.Read)
                {
                    throw new System.ArgumentException(access.ToString());
                }
                try
                {
                    var stream = new java.io.RandomAccessFile(path, "r");
                    stream.close();
                    throw new System.IO.IOException("Exists: " + path);
                }
                catch (java.io.FileNotFoundException)
                {
                }
                JavaChannel = new java.io.RandomAccessFile(path, "rw").getChannel();
                Flags       = CAN_WRITE | CAN_SEEK;
            }

            void CreateOrTruncate()
            {
                // create a new file or truncate an existing file
                if (access == System.IO.FileAccess.Read)
                {
                    throw new System.ArgumentException(access.ToString());
                }
                var stream = new java.io.RandomAccessFile(path, "rw");

                stream.setLength(0);
                JavaChannel = stream.getChannel();
                Flags       = CAN_WRITE | CAN_SEEK;
            }

            void OpenExisting()
            {
                // open existing file, throwing FileNotFoundException if cannot
                var stream = new java.io.RandomAccessFile(path, "r");

                if (access != System.IO.FileAccess.Read)
                {
                    // knowing the file exists, reopen for writing if necessary
                    stream.close();
                    stream = new java.io.RandomAccessFile(path, "rw");
                    Flags  = CAN_READ | CAN_WRITE | CAN_SEEK;
                }
                else
                {
                    Flags = CAN_READ | CAN_SEEK;
                }
                JavaChannel = stream.getChannel();
            }

            void OpenOrCreate()
            {
                // open existing file, or create a new file
                JavaChannel = new java.io.RandomAccessFile(path, "rw").getChannel();
                if (access != System.IO.FileAccess.Read)
                {
                    Flags = CAN_READ | CAN_WRITE | CAN_SEEK;
                }
                else
                {
                    Flags = CAN_READ | CAN_SEEK;
                }
            }

            void TruncateExisting()
            {
                // truncate existing file, or throws FileNotFoundException
                if (access == System.IO.FileAccess.Read)
                {
                    throw new System.ArgumentException(access.ToString());
                }
                var stream = new java.io.RandomAccessFile(path, "r");

                stream.close();
                stream = new java.io.RandomAccessFile(path, "rw");
                stream.setLength(0);
                JavaChannel = stream.getChannel();
                Flags       = CAN_WRITE | CAN_SEEK;
            }

            void AppendOrCreate()
            {
                var stream = new java.io.RandomAccessFile(path, "rw");

                stream.seek(stream.length());
                JavaChannel = stream.getChannel();
                Flags       = CAN_WRITE | CAN_SEEK;
            }
        }
示例#11
0
 public FileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share)
     : this(path, mode, access)
 {
 }
示例#12
0
 protected Package(System.IO.FileAccess openFileAccess)
 {
 }
示例#13
0
 protected override System.IO.Stream GetStreamCore(System.IO.FileMode streamFileMode, System.IO.FileAccess streamFileAccess)
 {
     return(default(System.IO.Stream));
 }
示例#14
0
 protected abstract System.IO.Stream GetStreamCore(System.IO.FileMode mode, System.IO.FileAccess access);
示例#15
0
		public FileStream Open(FileMode mode, FileAccess access, FileShare share)
		{
			return File.Open(FullPath, mode, access, share, 4096, FileOptions.SequentialScan);
		}
示例#16
0
 public System.IO.Stream GetStream(System.IO.FileMode mode, System.IO.FileAccess access)
 {
     return(default(System.IO.Stream));
 }
示例#17
0
 public static bool CanRead(this System.IO.FileAccess value)
 {
     return((value & System.IO.FileAccess.Read) != 0);
 }
示例#18
0
 /// <summary>
 /// Opens the specified access.
 /// </summary>
 /// <param name="access">The access.</param>
 /// <param name="sharing">The sharing.</param>
 /// <returns></returns>
 public abstract object Open(System.IO.FileAccess access, System.IO.FileShare sharing);
示例#19
0
 public static bool CanWrite(this System.IO.FileAccess value)
 {
     return((value & System.IO.FileAccess.Write) != 0);
 }
示例#20
0
 public NetworkStream(System.Net.Sockets.Socket socket, System.IO.FileAccess access)
 {
 }
示例#21
0
 public void StreamXml(KSoft.IO.XmlElementStream s, FA mode, XML.BXmlSerializerInterface xs)
 {
     Contract.Requires(s != null);
     Contract.Requires(mode != System.IO.FileAccess.ReadWrite);
     Contract.Requires(xs != null);
 }
示例#22
0
 public void StreamXml(KSoft.IO.XmlElementStream s, FA mode, XML.BXmlSerializerInterface xs)
 {
     XML.Util.Serialize(s, mode, xs, Skulls, BCollectibleSkull.kBListXmlParams);
 }
示例#23
0
        internal static System.IO.Stream Open(string name, System.IO.FileMode fileMode, System.IO.FileAccess fileAccess)
        {
#if FIRST_PASS
            return(null);
#else
            if (fileMode != System.IO.FileMode.Open || fileAccess != System.IO.FileAccess.Read)
            {
                throw new System.IO.IOException("vfs is read-only");
            }
            VfsFile entry = GetVfsEntry(name) as VfsFile;
            if (entry == null)
            {
                throw new System.IO.FileNotFoundException("File not found");
            }
            return(entry.Open());
#endif
        }
示例#24
0
 public void StreamXml(KSoft.IO.XmlElementStream s, FA mode, XML.BXmlSerializerInterface xs)
 {
     s.StreamCursorEnum(mode, ref mType);
     s.StreamAttributeEnumOpt(mode, kXmlAttrTarget, ref mTarget, e => e != BCollectibleSkullTarget.None);
     s.StreamAttributeOpt(mode, kXmlAttrValue, ref mValue, Util.kNotInvalidPredicateSingle);
 }
示例#25
0
 public static System.IO.FileStream Open(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share)
 {
     throw null;
 }
示例#26
0
 public FileStream Open(FileMode mode, FileAccess access)
 {
     return(Open(mode, access, FileShare.None));
 }
示例#27
0
 public System.IO.FileStream Open(System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share)
 {
     throw null;
 }
示例#28
0
 public XNetworkStream(Socket socket, System.IO.FileAccess access)
     : base(socket, access)
 {
 }
示例#29
0
            public Task <Stream> OpenFileAsync(string path, FileMode mode, FileAccess access, FileShare share)
            {
                Stream stream = _isolatedStorageFile.OpenFile(path, mode, access, share);

                return(Task.FromResult(stream));
            }
示例#30
0
		public FileStream Open(FileMode mode, FileAccess access)
		{
			return Open(mode, access, FileShare.None);
		}
示例#31
0
 /// <summary>
 /// Opens the IVfsNode and returns an object capable of doing something smart with the IVfsNode.
 /// </summary>
 /// <param name="access"></param>
 /// <param name="share"></param>
 /// <returns>
 /// An object instance, which represents the node.
 /// </returns>
 /// <remarks>
 /// This method is central to the entire VFS. It allows for interaction with filesystem entries in a way not possible
 /// with classical operating systems. The result of this function is heavily dependant on the item represented by the node, e.g.
 /// for a classic file (stream of bytes) the result of this method call would be a System.IO.Stream. For a device the result would
 /// be the driver object, for a directory it would be a System.IO.DirectoryInfo object, for kernel objects the respective object such
 /// as System.Threading.EventWaitHandle, System.Threading.Mutex, System.Threading.Thread, System.Diagnostics.Process etc. Note: The object
 /// retrieved can be closed by the respective methods on the returned object. There's no close functionality on the IVfsNode itself.
 /// </remarks>
 public override object Open(System.IO.FileAccess access, System.IO.FileShare share)
 {
     return(null);
 }
示例#32
0
 public SqlFileStream(string path, byte[] transactionContext, System.IO.FileAccess access)
 {
 }
示例#33
0
 public static System.IO.Packaging.Package Open(string path, System.IO.FileMode packageMode, System.IO.FileAccess packageAccess, System.IO.FileShare packageShare)
 {
     return(default(System.IO.Packaging.Package));
 }