示例#1
0
        public DiskFile(string name, DiskDirectory diskDirectory, Stream source,
                        bool overwrite = true, long offset = default, long length = default)
        {
            Name   = name;
            Parent = diskDirectory;
            if (!overwrite && File.Exists(Path))
            {
                throw new Exception("File already exists");
            }

            Write(source, offset, length);
        }
示例#2
0
        public DiskDirectory(
            string name, IDirectory?parent = null,
            bool createIfNotExists         = false)
        {
            _dirInfo = new DirectoryInfo(
                IoPath.Combine(parent?.Path ?? string.Empty, name));

            if (_dirInfo.Parent != null)
            {
                Parent = new DiskDirectory(_dirInfo.Parent.FullName);
            }

            Name = _dirInfo.Name;

            if (!createIfNotExists || _dirInfo.Exists)
            {
                return;
            }

            System.IO.Directory.CreateDirectory(_dirInfo.FullName);
            _dirInfo.Refresh();
        }