public IoResult AllocateChildrenHandles(IFileSystemHandle handle, out IFileSystemHandle[] childHandles) { var result = ReadOperation(() => AllocateChildrenHandlesInternal(handle)); childHandles = result.Item2; return(result.Item1); }
public IoResult ReadAllBytes(IFileSystemHandle handle, out byte[] bytes) { var internalHandle = handle as InternalHandle; if (internalHandle == null) { bytes = null; return(IoResult.InvalidHandle); } var path = internalHandle.Node.GetPath(); var fileInfo = new FileInfo(path); if (!fileInfo.Exists) { bytes = null; return(IoResult.NotFound); } else if (fileInfo.Attributes.HasFlag(FileAttributes.Directory)) { bytes = null; return(IoResult.InvalidOperation); } bytes = File.ReadAllBytes(path); return(IoResult.Success); }
public IoResult AllocateRelativeHandleFromPath(IFileSystemHandle baseNode, string relativePath, out IFileSystemHandle handle) { var result = ReadOperation(() => AllocateRelativeHandleFromPathInternal(baseNode, relativePath)); handle = result.Item2; return(result.Item1); }
protected internal GoogleDriveSession(GoogleDriveFileSystem fs, IFileSystemHandle handle, GoogleDriveParameters cParams) : base(fs, handle, cParams) { var email = (m_User.Credentials as GoogleDriveCredentials).Email; Client = new GoogleDriveClient(email, cParams.CertPath, cParams.TimeoutMs, cParams.Attempts); }
/// <summary> /// Internal method that should not be called by developers /// </summary> public FileSystemFile(FileSystemSession session, string parentPath, string name, IFileSystemHandle handle) : base(session, parentPath, name, handle) { }
public IoResult ReadAllBytes(IFileSystemHandle handle, out byte[] bytes) { var result = ReadOperation(() => ReadAllBytesInternal(handle)); bytes = result.Item2; return(result.Item1); }
protected internal S3V4FileSystemSession(S3V4FileSystem fs, IFileSystemHandle handle, S3V4FileSystemSessionConnectParams cParams) : base(fs, handle, cParams) { m_Bucket = cParams.Bucket; m_Region = cParams.Region; m_TimeoutMs = cParams.TimeoutMs; }
internal SVNFileSystemSession(SVNFileSystem fs, IFileSystemHandle handle, SVNFileSystemSessionConnectParams cParams) : base(fs, handle, cParams) { m_ServerURL = cParams.ServerURL; var cred = cParams.User.Credentials as IDPasswordCredentials; if (cred == null) m_WebDAV = new WebDAV(cParams.ServerURL, cParams.TimeoutMs); else m_WebDAV = new WebDAV(cParams.ServerURL, cParams.TimeoutMs, cred.ID, cred.Password); }
public IoResult GetPath(IFileSystemHandle handle, out string path) { var internalHandle = handle as InternalHandle; if (internalHandle == null || internalHandle.State == HandleState.Invalidated || internalHandle.State == HandleState.Disposed) { path = null; return(IoResult.InvalidHandle); } path = internalHandle.Node.GetPath(); return(IoResult.Success); }
public IoResult GetName(IFileSystemHandle handle, out string name) { var internalHandle = handle as InternalHandle; if (internalHandle == null || internalHandle.State == HandleState.Invalidated || internalHandle.State == HandleState.Disposed) { name = null; return(IoResult.InvalidHandle); } name = internalHandle.Node.Name; return(IoResult.Success); }
protected FileSystemSessionItem(FileSystemSession session, string parentPath, string name, IFileSystemHandle handle) { m_FileSystem = session.FileSystem; m_Session = session; m_ParentPath = parentPath; m_Handle = handle; m_Name = name; m_Session.m_Items.Add(this); }
protected FileSystemSessionItem(FileSystemSession session, string parentPath, string name, IFileSystemHandle handle) { m_FileSystem = session.FileSystem; m_Session = session; m_ParentPath = parentPath; m_Handle = handle; m_Name = name; m_Session.m_Items.Add( this ); }
protected internal DropBoxFileSystemSession(NFX.IO.FileSystem.FileSystem fs, IFileSystemHandle handle, FileSystemSessionConnectParams cParams) : base(fs, handle, cParams) { if(fs == null) throw new ArgumentNullException("fs"); if (cParams == null) throw new ArgumentNullException("cParams"); DropBoxFileSystemSessionConnectParams pr = cParams as DropBoxFileSystemSessionConnectParams; if (pr == null) throw new NFXException(StringConsts.FS_SESSION_BAD_PARAMS_ERROR + GetType() + ".ctor_DropBoxFileSystemSession"); ConnectParameters = pr; }
public IoResult AllocateChildrenHandles(IFileSystemHandle handle, out IFileSystemHandle[] childHandles) { var internalHandle = handle as InternalHandle; if (internalHandle == null) { childHandles = null; return(IoResult.InvalidHandle); } var children = internalHandle.Node.Children; childHandles = Util.Generate(children.Count, i => GetNodeHandle(children[i])); return(IoResult.Success); }
internal SVNFileSystemSession(SVNFileSystem fs, IFileSystemHandle handle, SVNFileSystemSessionConnectParams cParams) : base(fs, handle, cParams) { m_ServerURL = cParams.ServerURL; var cred = cParams.User.Credentials as IDPasswordCredentials; if (cred == null) { m_WebDAV = new WebDAV(cParams.ServerURL, cParams.TimeoutMs, log: fs.App.Log); } else { m_WebDAV = new WebDAV(cParams.ServerURL, cParams.TimeoutMs, cred.ID, cred.Password, log: fs.App.Log); } }
public void FreeHandle(IFileSystemHandle handle) { var internalHandle = handle as InternalHandle; if (internalHandle != null) { var referenceCount = internalHandle.DecrementReferenceCount(); if (referenceCount == 0) { lock (internalHandle) { if (internalHandle.GetReferenceCount() == 0) { internalHandle.Invalidate(); } } } } }
private Tuple <IoResult, IFileSystemHandle[]> AllocateChildrenHandlesInternal(IFileSystemHandle handle) { var internalHandle = handle as InternalHandle; if (internalHandle == null || internalHandle.State == HandleState.Invalidated || internalHandle.State == HandleState.Disposed) { return(new Tuple <IoResult, IFileSystemHandle[]>(IoResult.InvalidHandle, null)); } var children = internalHandle.Node.Children; var results = new IFileSystemHandle[children.Count]; var i = 0; foreach (var child in children) { results[i++] = GetNodeHandle(child); } return(new Tuple <IoResult, IFileSystemHandle[]>(IoResult.Success, results)); }
public Tuple <IoResult, byte[]> ReadAllBytesInternal(IFileSystemHandle handle) { var internalHandle = handle as InternalHandle; if (internalHandle == null || internalHandle.State == HandleState.Invalidated || internalHandle.State == HandleState.Disposed) { return(new Tuple <IoResult, byte[]>(IoResult.InvalidHandle, null)); } var asFile = internalHandle.Node as ReleaseManifestFileEntry; if (asFile == null) { // we have a directory return(new Tuple <IoResult, byte[]>(IoResult.InvalidOperation, null)); } IReadOnlyList <RiotArchive> archives; try { archives = GetArchivesOrNull(asFile.ArchiveId); } catch (ArchiveNotFoundException) { return(new Tuple <IoResult, byte[]>(IoResult.Unavailable, null)); } RAFFileListEntry entry = null; foreach (var archive in archives) { entry = archive.GetDirectoryFile().GetFileList().GetFileEntryOrNull(internalHandle.Node.GetPath()); if (entry != null) { break; } } if (entry == null) { return(new Tuple <IoResult, byte[]>(IoResult.NotFound, null)); } return(new Tuple <IoResult, byte[]>(IoResult.Success, entry.GetContent())); }
public IoResult AllocateRelativeHandleFromPath(IFileSystemHandle baseNode, string relativePath, out IFileSystemHandle handle) { var internalHandle = baseNode as InternalHandle; handle = null; if (internalHandle == null || internalHandle.State == HandleState.Invalidated || internalHandle.State == HandleState.Disposed) { return(IoResult.InvalidHandle); } var foundNode = internalHandle.Node.GetRelativeOrNull(relativePath); if (foundNode == null) { return(IoResult.NotFound); } handle = GetNodeHandle(foundNode); return(IoResult.Success); }
/// <summary> /// Starts new file system session /// </summary> protected internal FileSystemSession(FileSystem fs, IFileSystemHandle handle, FileSystemSessionConnectParams cParams) { if (fs == null || cParams == null) { throw new AzosIOException(StringConsts.FS_SESSION_BAD_PARAMS_ERROR.Args(GetType().FullName)); } ValidateConnectParams(cParams); m_FileSystem = fs; m_Handle = handle; m_User = cParams.User ?? User.Fake; m_Items = new List <FileSystemSessionItem>(); var name = cParams.Name; m_Name = name.IsNullOrWhiteSpace() ? "{0}.{1}".Args(m_User.Name, Guid.NewGuid()) : name; lock (m_FileSystem.m_Sessions) m_FileSystem.m_Sessions.Add(this); }
public LeagueMap LoadFromNVR(IFileSystem system, IFileSystemHandle mapFolderHandle) { // Find the .nvr file IFileSystemHandle nvrFileHandle; if (system.AllocateRelativeHandleFromPath(mapFolderHandle, @"Scene/room.nvr", out nvrFileHandle) != IoResult.Success) { throw new FileNotFoundException(); } // Read the file and put it into a stream for easy processing byte[] nvrFileRawData; if (system.ReadAllBytes(nvrFileHandle, out nvrFileRawData) != IoResult.Success) { throw new FileLoadException(); } using (var ms = new MemoryStream(nvrFileRawData)) { using (var reader = new BinaryReader(ms)) { var leagueMap = new LeagueMap(); // Check magic var magic = reader.ReadBytes(4); if (!magic.SequenceEqual(fileMagic)) { throw new Exception("NVR file magic number is not correct"); } // Read meta data leagueMap.majorVersion = reader.ReadUInt16(); leagueMap.minorVersion = reader.ReadUInt16(); var materialCount = reader.ReadInt32(); var vertexBufferCount = reader.ReadInt32(); var indexBufferCount = reader.ReadInt32(); var meshCount = reader.ReadInt32(); var aabbCount = reader.ReadInt32(); // Read materials leagueMap.materials = Util.Generate(materialCount, i => reader.ReadMaterial()); // Read vertex buffers raw data var vertexBuffers = Util.Generate(vertexBufferCount, i => reader.ReadVertexBufferRawData()); // Read index buffers leagueMap.indexBuffers = Util.Generate(indexBufferCount, i => reader.ReadIndexBuffer()); // Read meshes leagueMap.meshes = Util.Generate(meshCount, i => reader.ReadMesh()); // Classify the vertex buffers var vertexBufferTypes = new VertexType[vertexBufferCount]; foreach (var mesh in leagueMap.meshes) { vertexBufferTypes[mesh.simpleMesh.vertexBufferIndex] = VertexType.SIMPLE; vertexBufferTypes[mesh.complexMesh.vertexBufferIndex] = VertexType.COMPLEX; } // Parse the vertexBuffers leagueMap.vertexBuffers = Util.Generate(vertexBufferCount, i => ReadVertexBuffer(vertexBuffers[i], vertexBufferTypes[i])); // Read AABB data leagueMap.AABBs = new AABB[aabbCount]; for (var i = 0; i < aabbCount; ++i) { leagueMap.AABBs[i] = reader.ReadAABB(); var unknown1 = reader.ReadSingle(); var unknown2 = reader.ReadSingle(); var unknown3 = reader.ReadSingle(); } return(leagueMap); } } }
public FTPFileSystemSession(FTPFileSystem fs, IFileSystemHandle handle, FTPFileSystemSessionConnectParams cParams) : base(fs, handle, cParams) { m_Connection = new Session(); m_Connection.Open(cParams.Options); }
private Tuple <IoResult, IFileSystemHandle> AllocateRelativeHandleFromPathInternal(IFileSystemHandle baseNode, string relativePath) { var internalHandle = baseNode as InternalHandle; if (internalHandle == null || internalHandle.State == HandleState.Invalidated || internalHandle.State == HandleState.Disposed) { return(new Tuple <IoResult, IFileSystemHandle>(IoResult.InvalidHandle, null)); } var foundNode = internalHandle.Node.GetRelativeOrNull(relativePath); if (foundNode == null) { return(new Tuple <IoResult, IFileSystemHandle>(IoResult.NotFound, null)); } return(new Tuple <IoResult, IFileSystemHandle>(IoResult.Success, GetNodeHandle(foundNode))); }