public BinaryWriter AllocFile(out int handle) { ClusteredCachedStream.Cluster cluster = _stream.AllocCluster(null); handle = cluster.Handle; _stream.CurrentClusterHandle = handle; return(new BinaryWriter(_stream)); }
/// <summary> /// Resturns list of handles of all available files. /// </summary> /// <returns></returns> public IntArrayList GetAllFiles(bool idle) { int handle; IntHashSet deletedFiles = new IntHashSet(); handle = _stream.GetFirstFreeFileHandle(); while (IsValidHandle(handle) && Core.State != CoreState.ShuttingDown && (!idle || Core.IsSystemIdle)) { deletedFiles.Add(handle); ClusteredCachedStream.Cluster cluster = _stream.GetCluster(handle); handle = _stream.OffsetToHandle(cluster.NextOffset); } IntArrayList result = new IntArrayList(); for (long off = ClusteredCachedStream.BLOB_FILE_SYSTEM_HEADER_SIZE; off < _stream.Length;) { if (Core.State == CoreState.ShuttingDown || (idle && !Core.IsSystemIdle)) { break; } handle = _stream.OffsetToHandle(off); ClusteredCachedStream.Cluster cluster = _stream.GetCluster(handle); if (cluster.PrevOffset == ClusteredCachedStream.NOT_SET && !deletedFiles.Contains(handle)) { result.Add(handle); } off += cluster.Length; off += ClusteredCachedStream.CLUSTER_HEADER_SIZE; } return(result); }