/// <summary> /// Expands the size of a layer to at least [size] bytes. /// </summary> /// <param name="path">The path to the layer.</param> /// <param name="size">The size to expand the layer to in bytes. The layer will be expanded if size is larger than the current size of the layer.</param> public static void ExpandSandboxSize(string path, UInt64 size) { using (var info = new DriverInfoHelper()) { StorageFunctions.ExpandSandboxSize(ref info.Data, Path.GetFullPath(path), size); } }
/// <summary> /// Exports the contents a layer or sandbox to the specified directory. Only the files and /// registry keys that were changed are exported. /// </summary> /// <param name="path">The path to the layer or sandbox.</param> /// <param name="exportPath">The path of the exported files. This directory will be created and must not already exist.</param> /// <param name="layers">A list of parent layers.</param> public static void ExportLayer(string path, string exportPath, IList <Layer> layers) { path = Path.GetFullPath(path); if (Directory.Exists(exportPath)) { throw new IOException(string.Format("Directory {0} already exists.", exportPath)); } Directory.CreateDirectory(exportPath); try { using (var info = new DriverInfoHelper()) using (var descriptors = new LayerHelper(layers)) { StorageFunctions.ActivateLayer(ref info.Data, path); try { StorageFunctions.ExportLayer(ref info.Data, path, exportPath, descriptors.Data, descriptors.Data.Length); } finally { StorageFunctions.DeactivateLayer(ref info.Data, path); } } } catch (Exception) { Directory.Delete(exportPath, true); throw; } }
/// <summary> /// Destroys a layer or sandbox. /// </summary> /// <param name="path">The path to the layer or sandbox.</param> public static void DestroyLayer(string path) { using (var info = new DriverInfoHelper()) { StorageFunctions.DestroyLayer(ref info.Data, Path.GetFullPath(path)); } }
/// <summary> /// Dismounts a sandbox that was mounted but never dismounted. /// </summary> /// <param name="path">The path to the sandbox.</param> public static void DismountSandbox(string path) { using (var info = new DriverInfoHelper()) { StorageFunctions.DeactivateLayer(ref info.Data, path); } }
public void Dispose() { using (var info = new DriverInfoHelper()) { StorageFunctions.DeactivateLayer(ref info.Data, _path); } }
/// <summary> /// Creates a new layer from the exported contents of another layer. /// </summary> /// <param name="path">The path of the new layer.</param> /// <param name="importPath">The path of the exported files.</param> /// <param name="layers">A list of parent layers.</param> public static void ImportLayer(string path, string importPath, IList <Layer> layers) { using (var info = new DriverInfoHelper()) using (var descriptors = new LayerHelper(layers)) { StorageFunctions.ImportLayer(ref info.Data, Path.GetFullPath(path), importPath, descriptors.Data, descriptors.Data.Length); } }
/// <summary> /// Creates a new storage sandbox at the given directory path. /// </summary> /// <param name="path">A path to the new sandbox.</param> /// <param name="layers">A list of parent layers.</param> public static void CreateSandbox(string path, IList <Layer> layers) { using (var info = new DriverInfoHelper()) using (var descriptors = new LayerHelper(layers)) { StorageFunctions.CreateSandboxLayer(ref info.Data, Path.GetFullPath(path), null, descriptors.Data, descriptors.Data.Length); } }
internal MountedSandbox(string path, IList <Layer> layers) { using (var info = new DriverInfoHelper()) using (var descriptors = new LayerHelper(layers)) { StorageFunctions.ActivateLayer(ref info.Data, path); try { StorageFunctions.PrepareLayer(ref info.Data, path, descriptors.Data, descriptors.Data.Length); var mountPath = new StringBuilder(260); var length = new UIntPtr((uint)mountPath.Capacity); StorageFunctions.GetLayerMountPath(ref info.Data, path, ref length, mountPath); _mountPath = mountPath.ToString(); } catch (Exception) { StorageFunctions.DeactivateLayer(ref info.Data, path); throw; } } _path = path; }