/// <summary> /// Redirect and massaging /// </summary> /// <param name="storageType">https://www.eldos.com/documentation/cbfs/ref_cl_cbfs_prp_storagetype.html</param> /// <param name="threadPoolSize"></param> /// <param name="useInternalCaches"></param> /// <param name="iconRef"></param> public void CreateStorage(CbFsStorageType storageType, uint threadPoolSize, bool useInternalCaches, string iconRef = null) { Log.Trace("CreateStorage IN"); try { // Must set StorageType before mounting !! CbFs.StorageType = storageType; // Must set ThreadPoolSize before mounting !! CbFs.MinWorkerThreadCount = 1; CbFs.MaxWorkerThreadCount = threadPoolSize; CbFs.NonexistentFilesCacheEnabled = useInternalCaches; // https://www.eldos.com/documentation/cbfs/ref_cl_cbfs_prp_nonexistentfilescacheenabled.html CbFs.MetaDataCacheEnabled = useInternalCaches; // https://www.eldos.com/documentation/cbfs/ref_cl_cbfs_prp_metadatacacheenabled.html CbFs.FileCacheEnabled = useInternalCaches; // https://www.eldos.com/documentation/cbfs/ref_cl_cbfs_prp_filecacheenabled.html CbFs.ShortFileNameSupport = false; CbFs.ClusterSize = 0;// The value must be a multiple of sector size. Default value of 0 tells the driver to have cluster size equal to sector size. CbFs.SectorSize = 4096; // Make this a local style disk CbFs.StorageCharacteristics = 0; // https://www.eldos.com/forum/read.php?FID=13&TID=3681 // the CallAllOpenCloseCallbacks is going to be forced to be true in the next version, so ensure stuff work here with it. CbFs.CallAllOpenCloseCallbacks = true; // https://www.eldos.com/forum/read.php?FID=13&TID=479 // Pass the creation around, This can then be used to determine which of the already opened flags can be decremented to finally release the handle. CbFs.UseFileCreationFlags = true; // https://www.eldos.com/documentation/cbfs/ref_cl_cbfs_prp_usefilecreationflags.html CbFs.SerializeCallbacks = true; // https://www.eldos.com/documentation/cbfs/ref_cl_cbfs_prp_serializecallbacks.html CbFs.ParallelProcessingAllowed = false; // https://www.eldos.com/documentation/cbfs/ref_cl_cbfs_prp_parallelprocessingallowed.html CbFs.FileSystemName = "NTFS"; // Go create stuff CbFs.CreateStorage(); if (!string.IsNullOrWhiteSpace(iconRef)) { if (!CbFs.IconInstalled(iconRef)) { Log.ErrorException("!IconInstalled", new MissingSatelliteAssemblyException("Requested Icon ref is not installed: " + iconRef)); } else { CbFs.SetIcon(iconRef); } } CbFs.NotifyDirectoryChange("\"", CbFsNotifyFileAction.fanAdded, false); } catch (Exception ex) { CBFSWinUtil.BestAttemptToECBFSError(ex); } finally { Log.Trace("CreateStorage OUT"); } }
private void GetVolumeId(CallbackFileSystem Sender, ref uint volumeID) { Log.Trace("GetVolumeId IN"); try { volumeID = VolumeId; } catch (Exception ex) { CBFSWinUtil.BestAttemptToECBFSError(ex); } finally { Log.Trace("GetVolumeId OUT"); } }
private void SetVolumeLabel(CallbackFileSystem Sender, string volumeLabel) { Log.Trace("SetVolumeLabel IN"); try { VolumeLabel = volumeLabel; } catch (Exception ex) { CBFSWinUtil.BestAttemptToECBFSError(ex); } finally { Log.Trace("SetVolumeLabel OUT"); } }
private void GetVolumeSize(CallbackFileSystem Sender, ref long TotalNumberOfSectors, ref long NumberOfFreeSectors) { Log.Trace("GetVolumeSize IN"); try { GetVolumeSize(out TotalNumberOfSectors, out NumberOfFreeSectors); } catch (Exception ex) { CBFSWinUtil.BestAttemptToECBFSError(ex); } finally { Log.Trace("GetVolumeSize OUT"); } }
private void WriteFile(CallbackFileSystem Sender, CbFsFileInfo fileInfo, long Position, byte[] Buffer, int BytesToWrite, ref int bytesWritten) { Log.Trace("WriteFile IN"); uint written = 0; try { WriteFile(fileInfo, Position, Buffer, (uint)BytesToWrite, out written); } catch (Exception ex) { CBFSWinUtil.BestAttemptToECBFSError(ex); } finally { bytesWritten = (int)written; Log.Trace("WriteFile OUT"); } }
private void ReadFile(CallbackFileSystem Sender, CbFsFileInfo fileInfo, long Position, byte[] Buffer, int BytesToRead, ref int bytesRead) { Log.Trace("ReadFile IN"); uint read = 0; try { ReadFile(fileInfo, Position, Buffer, (uint)BytesToRead, out read); } catch (Exception ex) { CBFSWinUtil.BestAttemptToECBFSError(ex); } finally { bytesRead = (int)read; Log.Trace("ReadFile OUT"); } }
private void GetFileInfo(CallbackFileSystem Sender, string FileName, ref bool FileExists, ref DateTime CreationTime, ref DateTime LastAccessTime, ref DateTime LastWriteTime, ref long lengthOfFile, ref long AllocationSize, ref CBFS_LARGE_INTEGER FileId, ref uint FileAttributes, ref string ShortFileName, ref string RealFileName) { Log.Trace("GetFileInfo IN"); try { GetFileInfo(FileName, ref FileExists, ref CreationTime, ref LastAccessTime, ref LastWriteTime, ref lengthOfFile, ref AllocationSize, ref FileId, ref FileAttributes, ref ShortFileName, ref RealFileName); } catch (Exception ex) { CBFSWinUtil.BestAttemptToECBFSError(ex); } finally { Log.Trace("GetFileInfo OUT"); } }
private void EnumerateDirectory(CallbackFileSystem Sender, CbFsFileInfo directoryInfo, CbFsHandleInfo HandleInfo, CbFsDirectoryEnumerationInfo DirectoryEnumerationInfo, string Mask, int Index, [MarshalAs(UnmanagedType.U1)] bool Restart, ref bool FileFound, ref string FileName, ref string ShortFileName, ref DateTime CreationTime, ref DateTime LastAccessTime, ref DateTime LastWriteTime, ref long lengthOfFile, ref long AllocationSize, ref CBFS_LARGE_INTEGER FileId, ref uint FileAttributes) { Log.Trace("EnumerateDirectory IN"); try { EnumerateDirectory(directoryInfo, HandleInfo, DirectoryEnumerationInfo, Mask, Restart, ref FileFound, ref FileName, ref ShortFileName, ref CreationTime, ref LastAccessTime, ref LastWriteTime, ref lengthOfFile, ref AllocationSize, ref FileId, ref FileAttributes); } catch (Exception ex) { CBFSWinUtil.BestAttemptToECBFSError(ex); } finally { Log.Trace("EnumerateDirectory OUT"); } }