public Stream GetStream(string storageId, string storageAccessKey, StorageMode mode, string downloadHost, string filePath, string fileName) { CloudBlobContainer container = GetContainer(storageId, storageAccessKey, mode, filePath); //if (string.IsNullOrEmpty(filePath)) //{ // filePath = DEFAULT_CONTAINER; //} // write a blob to the container CloudBlockBlob blob = container.GetBlockBlobReference( Path.Combine(filePath, fileName)); var temp = blob.ExistsAsync(); temp.Wait(); if (temp.Result == false) { return(null); } var task = blob.OpenReadAsync(); task.Wait(); return(task.Result); }
/// <summary> /// ストリームを開く /// </summary> /// <param name="board">書き込む板のヘッダ情報</param> /// <param name="modeRead">ストレージを開く方法</param> public override bool Open(BoardInfo board, StorageMode mode) { if (board == null) { throw new ArgumentNullException("board"); } if (isOpen) { throw new InvalidCastException("既にストリームが開かれています"); } // 書き込み先ファイル名 string filePath = Path.Combine(cache.GetFolderPath(board), "subject.txt"); // ストリームを開く if (mode == StorageMode.Read) { baseStream = StreamCreator.CreateReader(filePath, false); } else { baseStream = StreamCreator.CreateWriter(filePath, false, false); } // パーサを初期化 dataParser = new X2chThreadListParser(board.Bbs, encoding); this.index = 1; this.position = 0; this.mode = mode; this.isOpen = true; this.boardInfo = board; return(true); }
/// <summary> /// Opens a Storage using the specified opener. /// </summary> /// <param name="name">The name of the substorage.</param> /// <param name="mode">The Storagemode to open the substorage.</param> /// <param name="writable">Whether to open the storage as writable. If /// the parent storage is readonly, the substorage cannot be opened /// as writable (InvalidoperationException will be thrown).</param> /// <param name="opener">The IStorageOpener to use to open the storage.</param> /// <param name="created">Out parameter indicated whether the storage was created (or opened)</param> /// <returns>The Storage.</returns> internal static IStorage OpenStorage(string name, StorageMode mode, bool writable, IStorageOpener opener) { IStorage storage = null; try { switch (mode) { case (StorageMode.Create): opener.CreateStorage(name, out storage); break; case (StorageMode.Open): if (!opener.OpenStorage(name, writable, out storage)) { throw new COMException("StorageName does not exist", STG_E.FILENOTFOUND); } break; case (StorageMode.OpenOrCreate): if (!opener.OpenStorage(name, writable, out storage)) { opener.CreateStorage(name, out storage); } break; } } catch (COMException e) { ThrowStorageException(e); } return(storage); }
public static void SetItem(string key, string value, StorageMode mode) { switch (mode) { case StorageMode.LocalStorage: window.localStorage.setItem(key, value); break; case StorageMode.SessionStorage: window.sessionStorage.setItem(key, value); break; case StorageMode.DictinaryStorage: if (_innerStorage.ContainsKey(key)) { _innerStorage[key] = value; } else { _innerStorage.Add(key, value); } break; } }
/// <summary> /// Same as InitWithStream(IStream, StorageMode). /// </summary> /// <exception cref="COMException">See InitWithStream(IStream, StorageMode).</exception> /// <exception cref="ArgumentOutOfRangeException">See InitWithStream(IStream, StorageMode).</exception> /// <param name="path">The path to the file.</param> /// <param name="mode">The storage mode.</param> /// <returns>True or false, see InitWithStream(IStream, StorageMode).</returns> public bool InitWithFile(string path, StorageMode mode) { EnsureNotDisposed(); EnsureNotInitialized(); if (mode != StorageMode.Read && mode != StorageMode.ReadWrite) { throw new ArgumentOutOfRangeException("mode", mode, "The argument mode must be Read or ReadWrite."); } var iwf = previewHandler as IInitializeWithFile; if (iwf == null) { return(false); } var hr = iwf.Initialize(path, mode); if (hr == HResult.E_NOTIMPL) { return(false); } if ((int)hr < 0) { throw new COMException("IInitializeWithFile.Initialize failed.", (int)hr); } init = true; return(true); }
/// <summary> /// Tries to initialize the preview handler with an IStream. /// </summary> /// <exception cref="COMException">This exception is thrown if IInitializeWithStream.Initialize fails for reason other than E_NOTIMPL.</exception> /// <exception cref="ArgumentOutOfRangeException">Thrown if mode is neither Read nor ReadWrite.</exception> /// <param name="stream">The IStream interface used to initialize the preview handler.</param> /// <param name="mode">The storage mode, must be Read or ReadWrite.</param> /// <returns>If the handler supports initialization with IStream, true; otherwise, false.</returns> public bool InitWithStream(IStream stream, StorageMode mode) { if (mode != StorageMode.Read && mode != StorageMode.ReadWrite) { throw new ArgumentOutOfRangeException("mode", mode, "The argument mode must be Read or ReadWrite."); } var iws = previewHandler as IInitializeWithStream; if (iws == null) { return(false); } var hr = iws.Initialize(stream, mode); if (hr == HResult.E_NOTIMPL) { return(false); } if ((int)hr < 0) { throw new COMException("IInitializeWithStream.Initialize failed.", (int)hr); } init = true; return(true); }
/// <summary> /// Get rank feed table /// </summary> /// <param name="containerName">Container name</param> /// <param name="containerInitial">Container initial</param> /// <param name="tableName">Table name</param> /// <param name="tableInitial">Table initial</param> /// <param name="storageMode">Storage mode</param> /// <param name="maxFeedSizeInCache">Max feed size in cache</param> /// <param name="order">Order of items</param> /// <returns>Rank feed table</returns> public static RankFeedTable GetRankFeedTable( string containerName, string containerInitial, string tableName, string tableInitial, StorageMode storageMode = StorageMode.Default, int maxFeedSizeInCache = int.MaxValue, FeedOrder order = FeedOrder.Ascending) { ValidateTableParameters(containerName, containerInitial, tableName, tableInitial); if (storageMode != StorageMode.CacheOnly) { throw new NotSupportedException("Rank feed tables are supported only in cache-only mode"); } return(new RankFeedTable() { ContainerName = containerName, ContainerInitial = containerInitial, TableName = tableName, TableInitial = tableInitial, StorageMode = storageMode, MaxFeedSizeInCache = maxFeedSizeInCache, Order = order }); }
public unsafe static object CreateStorage( string path, Guid riid, StorageMode mode = StorageMode.ReadWrite | StorageMode.Create | StorageMode.ShareExclusive, StorageFormat format = StorageFormat.DocFile) { STGOPTIONS options = new STGOPTIONS { usVersion = 1, // If possible, we want the larger 4096 sector size ulSectorSize = (mode & StorageMode.Simple) != 0 ? 512u : 4096 }; Imports.StgCreateStorageEx( path, mode, format, 0, format == StorageFormat.DocFile ? &options : null, null, ref riid, out object created).ThrowIfFailed(path); return(created); }
/// <summary> /// 出力ストリームを開く /// </summary> /// <param name="header">書き込むスレッドのヘッダ情報</param> /// <param name="mode">ストレージを開く方法</param> public override bool Open(ThreadHeader header, StorageMode mode) { if (header == null) { throw new ArgumentNullException("header"); } if (isOpen) { throw new InvalidCastException("既にストリームが開かれています"); } // 書き込み先ファイル名 string filePath = cache.GetDatPath(header); // ストリームを開く if (mode == StorageMode.Read) { baseStream = StreamCreator.CreateReader(filePath, header.UseGzip); } else { baseStream = StreamCreator.CreateWriter(filePath, header.UseGzip, true); } this.mode = mode; this.index = 1; this.position = 0; this.isOpen = true; return(true); }
public override void Save(CatalogPageViewModel instance, StorageMode mode) { instance.SavedInTombstone = true; instance.SaveState(instance.ToString()); base.Save(instance, mode); }
public StorageSystem(String appDataPath, String localPath, String virtualDirectory, String trainingRunPath, int dummy) { _appDataPath = appDataPath; _storageMode = StorageMode.Local; _directorySeparator = "\\"; _localPath = localPath; _localTrainingRunPath = trainingRunPath; _virtualDirectory = virtualDirectory; }
public ResourceProperty(StorageMode storage = StorageMode.NonVolatile, bool serialize = true, string readAnnotation = null, string writeAnnotation = null) { this.ReadAnnotation = readAnnotation; this.WriteAnnotation = writeAnnotation; this.Storage = storage; this.Serialize = serialize; }
/// <summary> /// Opens a Storage in this storage. /// </summary> /// <param name="name">The guid representing the name of the substorage.</param> /// <param name="mode">The Storagemode to open the substorage.</param> /// <param name="writable">Whether to open the storage as writable. If /// the parent storage is readonly, the substorage cannot be opened /// as writable (StorageInvalidOperationException will be thrown).</param> /// <returns>The Storage.</returns> public Storage OpenStorage(Guid name, StorageMode mode, bool writable) { bool openWritable = ResolveWritableOverride(writable); return(new Storage( OpenStorage(NameFromGuid(name), mode, openWritable, new SubStorageOpener(this.storage)), openWritable )); }
public unsafe static extern HResult StgCreateStorageEx( string pwcsName, StorageMode grfMode, StorageFormat stgfmt, FileFlags grfAttrs, STGOPTIONS *pStgOptions, SECURITY_DESCRIPTOR **pSecurityDescriptor, ref Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppObjectOpen);
public unsafe static extern HResult StgOpenStorageEx( string pwcsName, StorageMode grfMode, StorageFormat stgfmt, FileFlags grfAttrs, STGOPTIONS *pStgOptions, void *reserved2, ref Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppObjectOpen);
public static Database FromResources(string name, string resources = "C://", StorageMode mode = StorageMode.Safe) { Database db = new Database(name, resources, mode); db.LoadIndex(); return(db); }
/// <summary> /// Opens a Storage in this storage. /// </summary> /// <param name="name">The string representing the name of the substorage (31 characters or less).</param> /// <param name="mode">The Storagemode to open the substorage.</param> /// <param name="writable">Whether to open the storage as writable. If /// the parent storage is readonly, the substorage cannot be opened /// as writable (StorageInvalidOperationException will be thrown).</param> /// <returns>The Storage.</returns> public Storage OpenStorage(string name, StorageMode mode, bool writable) { bool openWritable = ResolveWritableOverride(writable); return(new Storage( OpenStorage(name, mode, openWritable, new SubStorageOpener(this.storage)), openWritable )); }
/// <summary> /// Initializes a new instance of the <see cref="StorageCoordinator"/> class. /// </summary> /// <param name="storageMechanisms">The storage mechanisms.</param> /// <param name="handlers">The handlers.</param> public StorageCoordinator(IEnumerable <IStorageMechanism> storageMechanisms, IEnumerable <IStorageHandler> handlers) { this.storageMechanisms = storageMechanisms.ToList(); handlers.Apply(x => AddStorageHandler(x)); Application.Current.Resuming += (sender, o) => { currentRestoreMode = StorageMode.Any; }; }
protected AbstractDataFile(string filename) { UnpackedFilename = filename; Mode = StorageMode.UnpackedFile; if (filename == null) { SourceFilename = null; } else { SourceFilename = Path.Combine(filename); Load(); } }
public StorageSystem( String appDataPath, String accessKey, String secretKey ) { _appDataPath = appDataPath; _storageMode = StorageMode.S3; _directorySeparator = "/"; _accessKey = accessKey; _secretKey = secretKey; }
/// <summary> /// Restores the specified instance. /// </summary> /// <param name="instance">The instance.</param> /// <param name="restoreMode">The restore mode.</param> public void Restore(object instance, StorageMode restoreMode = StorageMode.Automatic) { var handler = GetStorageHandlerFor(instance); if (handler == null) { return; } tracked.Add(new WeakReference(instance)); handler.Restore(instance, restoreMode == StorageMode.Automatic ? currentRestoreMode : restoreMode); }
/// <summary> /// Initializes a new instance of the <see cref="StorageCoordinator"/> class. /// </summary> /// <param name="container">The container.</param> /// <param name="phoneService">The phone service.</param> /// <param name="storageMechanisms">The storage mechanisms.</param> /// <param name="handlers">The handlers.</param> public StorageCoordinator(IPhoneContainer container, IPhoneService phoneService, IEnumerable<IStorageMechanism> storageMechanisms, IEnumerable<IStorageHandler> handlers) { this.container = container; this.phoneService = phoneService; this.storageMechanisms = storageMechanisms.ToList(); handlers.Apply(x => AddStorageHandler(x)); phoneService.Resurrecting += () => currentRestoreMode = StorageMode.Any; phoneService.Continuing += () => storageMechanisms.Apply(x => x.ClearLastSession()); }
/// <summary> /// Uses this handler to restore a particular instance using instructions that support the provided mode. /// </summary> /// <param name="instance">The instance.</param> /// <param name="mode">The mode.</param> public virtual void Restore(T instance, StorageMode mode) { foreach (var instruction in instructions) { var key = instruction.Key; if (instruction.StorageMechanism.Supports(mode)) { instruction.Restore(instance, () => GetKey(instance, key), mode); } } }
private string ExtractEndPoint(StorageMode mode, JObject keyObject) { if (IsDebug) { return(keyObject.Value <string>("OutputEndPoint")); } if (mode == StorageMode.External) { return(keyObject.Value <string>("OutputEndPoint")); } return(keyObject.Value <string>("DownloadEndPoint")); }
/// <summary> /// Saves all monitored instances according to the provided mode. /// </summary> /// <param name="saveMode">The save mode.</param> public void Save(StorageMode saveMode) { var toSave = tracked.Select(x => x.Target).Where(x => x != null); var mechanisms = storageMechanisms.Where(x => x.Supports(saveMode)); mechanisms.Apply(x => x.BeginStoring()); foreach(var item in toSave) { var handler = GetStorageHandlerFor(item); handler.Save(item, saveMode); } mechanisms.Apply(x => x.EndStoring()); }
protected AbstractDataFile(string carDir, string filename, Acd loadedAcd) { UnpackedFilename = filename; var acdFile = Path.Combine(carDir, "data.acd"); if (loadedAcd != null || File.Exists(acdFile)) { Mode = StorageMode.AcdFile; SourceFilename = acdFile; } else { Mode = StorageMode.UnpackedFile; SourceFilename = Path.Combine(carDir, "data", filename); } Load(loadedAcd); }
/// <summary> /// 获取文档存储模式 /// </summary> /// <returns>StorageMode枚举</returns> public StorageMode GetStorageMode() { if (this.m_eStorageMode != StorageMode.Unknown) { return(this.m_eStorageMode); } if (this.m_ConfigAccess == null) { this.m_ConfigAccess = new ConfigAccess(); } this.m_eStorageMode = this.m_ConfigAccess.GetStorageMode(); return(this.m_eStorageMode); }
public bool WriteToRVTFile(string rvtFilePath, BasicFileInfo basicFileInfo) { if (!File.Exists(rvtFilePath)) { return(false); } StorageMode grfMode = StorageMode.ReadWrite | StorageMode.ShareExclusive; OleRootStorage oleRootStorage = new OleRootStorage(); string text = null; try { if (!oleRootStorage.Open(rvtFilePath, (int)grfMode)) { return(false); } var modelDataStreamIdentifier = new ModelDataStreamIdentifier(ModelDataStreamType.mdstBasicFileInfo); OleStream oleStream = oleRootStorage.OpenStream(modelDataStreamIdentifier.StreamName, grfMode); text = Path.GetTempFileName(); if (!WriteToStreamFile(text, basicFileInfo)) { return(false); } if (!oleStream.Import(text)) { return(false); } oleStream.Commit(); oleRootStorage.Commit(); } catch (Exception) { return(false); } finally { if (text != null) { try { File.Delete(text); } catch (Exception) { } } oleRootStorage.Close(isSave: true); } return(true); }
public virtual string GetBundleUri(string bundleName, StorageMode storageMode) { var bundleBaseUri = storageMode == StorageMode.Remote ? Config.ServerUriLocator.GetServerUri(bundleName) : Application.streamingAssetsPath; if (!bundleBaseUri.EndsWith("/")) { bundleBaseUri += "/"; } var bundleUri = String.Format("{0}{1}{2}{3}", bundleBaseUri, AssetBundleData.GetPlatformName() + "/", AssetBundle.DelightAssetsFolder, bundleName.ToLower()); return(bundleUri); }
protected AbstractDataFile([CanBeNull] string filename) { Mode = StorageMode.UnpackedFile; if (filename == null) { Name = ""; Filename = null; } else { Name = Path.GetFileName(filename); Filename = filename; Load(); } }
/// <summary> /// Constructor from array. /// </summary> /// <param name="members"></param> /// <param name="createMode"></param> /// <param name="storageMode"></param> public ListBounded(T[] members, CopyMode createMode, StorageMode storageMode = StorageMode.AllocatedArray) { Debug.Assert(!(createMode == CopyMode.ReferencePassedMembers && storageMode == StorageMode.RentedArrayPool)); // inconsistent MaxLength = length = members.Length; if (createMode == CopyMode.ReferencePassedMembers) { array = members; } else { DoCreate(members.Length, storageMode); Array.Copy(members, array, members.Length); } }
private void GetClient(StorageMode mode, string storageId, string storageAccessKey, string filePath, string fileName, out string bucketName, out string objectName, out OssClient client) { JObject jobject = JObject.Parse(storageAccessKey); string endpoint = ExtractEndPoint(mode, jobject); // "<yourEndpoint>"; string accessKeyId = ExtractAccessKeyId(jobject); //"<yourAccessKeyId>"; string accessKeySecret = ExtractAccessKeySecret(jobject); //"<yourAccessKeySecret>"; bucketName = storageId; objectName = $"{filePath.Trim(new char[] { '/', '\\' })}/{fileName}"; //Path.Combine(filePath, fileName); //var localFilename = "<yourLocalFilename>"; // 创建OssClient实例。 client = new OssClient(endpoint, accessKeyId, accessKeySecret); }
public CandlesPersistenceQueue( ICandlesHistoryRepository repository, ILog log, IHealthService healthService, PersistenceSettings settings, StorageMode stmP) : base(nameof(CandlesPersistenceQueue), log) { _repository = repository; _log = log; _healthService = healthService; _settings = settings; _candlesToDispatch = new ConcurrentQueue <ICandle>(); _storageMode = stmP; }
public async Task <List <Movie> > ScanMoviesAndStoreThemAsync(StorageMode storageMode, CancellationToken ct, params string[] paths) { var movies = new List <Movie>(); List <string> hardDrives = new List <string>(paths.Length); string[] pathsTable = new string[paths.Length]; for (var i = 0; i < paths.Length; i++) { var path = paths[i]; pathsTable[i] = path; hardDrives.Add(GeneralRules.GetHardDrive(path)); _logger.LogInformation($"Request scan movies on {path}"); movies.AddRange(_movieScanner.ScanForMovies(path, ct)); } hardDrives.Sort(string.Compare); string fileStorageName = string.Empty; foreach (var hardDrive in hardDrives) { fileStorageName += hardDrive + "_"; } fileStorageName += "Movies.json"; string storagePath = paths[0] + $"\\{fileStorageName}"; ct.ThrowIfCancellationRequested(); switch (storageMode) { case StorageMode.Override: { _logger.LogInformation($"Request store movies on {storagePath}"); await _movieStorage.OverrideMovieListAsync(movies, storagePath, ct); break; } } return(movies); }
/// <summary> /// Creates a new file entry in the archive using the provided path and data. /// </summary> /// <param name="path">The path of the entry in the archive.</param> /// <param name="data">The data of the entry.</param> /// <param name="storageMode"> /// If storageMode is not StorageMode.Plain, data will be compressed accordingly. /// </param> /// <exception cref="ArgumentNullException">path or data are <see cref="null"/>.</exception> /// <exception cref="ArgumentException"> /// The specified path is invalid or the specified storage mode is not supported. /// </exception> /// <returns>The <see cref="ArcEntry"/> instance of the new entry.</returns> /// <remarks>Locks the data object.</remarks> public ArcEntry CreateEntry(string path, byte[] data, StorageMode storageMode) { lock (data) lock (_lock) { ThrowIfDisposed(); ThrowIfReadOnly(); if (path == null) throw new ArgumentNullException("Path cannot be null.", "path"); if (!PathUtils.EntryAbsolutePathRegex.IsMatch(path)) throw new ArgumentException("The specified path is invalid.", "path"); if (data == null) throw new ArgumentNullException("Data cannot be null.", "data"); if (!Enum.IsDefined(typeof(StorageMode), storageMode)) throw new ArgumentException("The specified storage mode is not supported.", "storageMode"); byte[] writeData = data; if (storageMode == StorageMode.Lz4Compressed) { writeData = new byte[Lz4.CompressBound(data.Length)]; var cSize = Lz4.CompressDefault(data, writeData, data.Length, writeData.Length); Array.Resize(ref writeData, cSize); } _stream.Seek(_header.FooterPointer, SeekOrigin.Begin); var chunk = new ArcStruct.Chunk() { DataPointer = (uint)_stream.Position, CompressedSize = (uint)writeData.Length, PlainSize = (uint)data.Length }; _writer.Write(writeData); writeData = null; var entry = new ArcEntry( this, new ArcStruct.Entry() { StorageMode = (uint)storageMode, DataPointer = chunk.DataPointer, CompressedSize = chunk.CompressedSize, PlainSize = chunk.PlainSize, Adler32 = Checksum(data), FileTime = DateTime.Now.ToFileTime() // The other fields will be set by UpdateMeta() }, path, new ArcStruct.Chunk[] { chunk } ); _entries.Add(entry); UpdateMeta((uint)_stream.Position); return entry; } }
public bool Supports(StorageMode mode) { return mode == StorageMode.Tombstone; }
/// <summary> /// Opens a Storage using the specified opener. /// </summary> /// <param name="name">The name of the substorage.</param> /// <param name="mode">The Storagemode to open the substorage.</param> /// <param name="writable">Whether to open the storage as writable. If /// the parent storage is readonly, the substorage cannot be opened /// as writable (InvalidoperationException will be thrown).</param> /// <param name="opener">The IStorageOpener to use to open the storage.</param> /// <param name="created">Out parameter indicated whether the storage was created (or opened)</param> /// <returns>The Storage.</returns> internal static IStorage OpenStorage(string name, StorageMode mode, bool writable, IStorageOpener opener) { IStorage storage = null; try { switch (mode) { case (StorageMode.Create): opener.CreateStorage(name, out storage); break; case (StorageMode.Open): if (!opener.OpenStorage(name, writable, out storage)) { throw new COMException("StorageName does not exist", STG_E.FILENOTFOUND); } break; case (StorageMode.OpenOrCreate): if (!opener.OpenStorage(name, writable, out storage)) { opener.CreateStorage(name, out storage); } break; } } catch (COMException e) { ThrowStorageException(e); } return storage; }
public static void SetupLargeStreamStorage() { LargeStreamStorage = new Dictionary<string, LargeStream>(); ProviderStorageMode = StorageMode.LargeStream; }
/// <summary> /// Opens a stream in this storage. /// </summary> /// <param name="name">The string representing the name of the stream to open.</param> /// <param name="mode">The storagemode to use when opening the stream.</param> /// <param name="writable">Whether to open the stream as writable. If /// the parent storage is readonly, the stream cannot be opened /// as writable (StorageInvalidOperationException will be thrown).</param> /// <returns>The stream.</returns> public ComStream OpenStream(Guid guid, StorageMode mode, bool writable) { return OpenStream(NameFromGuid(guid), mode, writable); }
/// <summary> /// Indicates what storage modes this mechanism provides. /// </summary> /// <param name="mode">The storage mode to check.</param> /// <returns> /// Whether or not it is supported. /// </returns> public bool Supports(StorageMode mode) { return (mode & StorageMode.Permanent) == StorageMode.Permanent; }
/// <summary> /// Opens a stream in this storage. /// </summary> /// <param name="name">The string representing the name of the stream to open.</param> /// <param name="mode">The storagemode to use when opening the stream.</param> /// <returns>The stream.</returns> public ComStream OpenStream(string name, StorageMode mode) { return OpenStream(name, mode, Writable); }
/// <summary> /// Opens a stream in this storage. /// </summary> /// <param name="name">The guid representing the name of the stream to open.</param> /// <param name="mode">The storagemode to use when opening the stream.</param> /// <param name="writable">Whether to open the stream as writable. If /// the parent storage is readonly, the stream cannot be opened /// as writable (StorageInvalidOperationException will be thrown).</param> /// <returns>The stream.</returns> public ComStream OpenStream(string name, StorageMode mode, bool writable) { bool openWritable = ResolveWritableOverride(writable); ComStream stream = null; try { switch (mode) { case (StorageMode.Create): CreateStream(name, out stream); break; case (StorageMode.Open): OpenStream(name, openWritable, out stream); break; case (StorageMode.OpenOrCreate): try { OpenStream(name, true, out stream); } catch (COMException e) { if (e.ErrorCode == STG_E.FILENOTFOUND) CreateStream(name, out stream); else throw; } break; } } catch (COMException e) { ThrowStorageException(e); } return stream; }
/// <summary> /// Opens a Storage in this storage. /// </summary> /// <param name="name">The guid representing the name of the substorage.</param> /// <param name="mode">The Storagemode to open the substorage.</param> /// <param name="writable">Whether to open the storage as writable. If /// the parent storage is readonly, the substorage cannot be opened /// as writable (StorageInvalidOperationException will be thrown).</param> /// <returns>The Storage.</returns> public Storage OpenStorage(Guid name, StorageMode mode, bool writable) { bool openWritable = ResolveWritableOverride(writable); return new Storage( OpenStorage(NameFromGuid(name), mode, openWritable, new SubStorageOpener(this.storage)), openWritable ); }
/// <summary> /// Opens a Storage in this storage. /// </summary> /// <param name="name">The guid representing the name of the substorage.</param> /// <param name="mode">The Storagemode to open the substorage.</param> /// <returns>The Storage.</returns> public Storage OpenStorage(Guid name, StorageMode mode) { return OpenStorage(name, mode, Writable); }
/// <summary> /// Creates a new compound file storage object. /// </summary> /// <param name="storageFile">The compound file being created.</param> /// <param name="mode">Specifies the access mode to use when opening the new storage object.</param> /// <returns>The created Storage object.</returns> public static Storage CreateDocFile(string storageFile, StorageMode mode) { IStorage storage = NativeMethods.StgCreateDocfile(storageFile, (uint)mode, 0); return new Storage(storage); }
/// <summary> /// Opens an existing root storage object in the file system. /// </summary> /// <param name="storageFile">The file that contains the storage object to open.</param> /// <param name="mode">Specifies the access mode to use to open the storage object.</param> /// <returns>The created Storage object.</returns> public static Storage Open(string storageFile, StorageMode mode) { IStorage storage = NativeMethods.StgOpenStorage(storageFile, IntPtr.Zero, (uint)mode, IntPtr.Zero, 0); return new Storage(storage); }
/// <summary> /// Indicates what storage modes this mechanism provides. /// </summary> /// <param name="mode">The storage mode to check.</param> /// <returns> /// Whether or not it is supported. /// </returns> public bool Supports(StorageMode mode) { return (mode & StorageMode.Temporary) == StorageMode.Temporary; }
/// <summary> /// Method to get the Session Properties from a loaded session. /// </summary> protected virtual void GetAllProperties() { sessionFileName = implementation.SessionFileName; resultsRootDirectory = implementation.ResultsRootDirectory; definitionRootDirectory = implementation.DefinitionManagement.DefinitionFileRootDirectory; //descriptionDirectory = implementation.DescriptionDirectory; date = implementation.Date; sessionTitle = implementation.SessionTitle; sessionId = implementation.SessionId;; softwareVersions = implementation.SoftwareVersions; testedBy = implementation.TestedBy; manufacturer = implementation.Manufacturer; modelname = implementation.ModelName; autoCreateDirectory = implementation.AutoCreateDirectory; continueOnError = implementation.ContinueOnError; logLevelFlagsMask = (int)implementation.LogLevelFlags; storageMode = Convert(implementation.StorageMode); dataDirectory = implementation.DataDirectory; validateReferencedFile = implementation.ValidateReferencedFile; displayConditionText = implementation.DisplayConditionText; detailedValidationResults = implementation.DetailedValidationResults; }
public bool Supports(StorageMode mode) { return mode == StorageMode.Shutdown; }
/// <summary> /// Opens a Storage in this storage. /// </summary> /// <param name="name">The string representing the name of the substorage (31 characters or less).</param> /// <param name="mode">The Storagemode to open the substorage.</param> /// <param name="writable">Whether to open the storage as writable. If /// the parent storage is readonly, the substorage cannot be opened /// as writable (StorageInvalidOperationException will be thrown).</param> /// <returns>The Storage.</returns> public Storage OpenStorage(string name, StorageMode mode, bool writable) { bool openWritable = ResolveWritableOverride(writable); return new Storage( OpenStorage(name, mode, openWritable, new SubStorageOpener(this.storage)), openWritable ); }
/// <summary> /// Constructor for Storage based on a file path /// </summary> /// <param name="storage">The IStorage from which to construct this storage.</param> /// <param name="writable">Whether the storage is writable.</param> public Storage(string path, StorageMode mode, bool writable) : this(OpenStorage(path, mode, writable, new CompoundFileOpener()), writable) { }