public static bool CallSH(FileOperationType type, string[] from, string to, FileOperationFlags flags) { var fs = new SHFILEOPSTRUCT(); fs.wFunc = type; if (from.Length > 0) fs.pFrom = string.Join("\0", from) + "\0\0"; if (to.Length > 0) fs.pTo = to + "\0\0"; fs.fFlags = flags; return SHFileOperation(ref fs) == 0; }
/// <summary> /// If this version of the constructor is used for a Delete opration, the dest path is ignored. /// </summary> /// <param name="source"></param> /// <param name="dest"></param> /// <param name="max_time"></param> /// <param name="opType"></param> public FileOperation(string source, string dest, long max_time = 0, FileOperationType opType = FileOperationType.Move) { if (max_time > 0) { this.maxWaitTime = max_time; } this.type = opType; this.sourcePath = source; this.destPath = dest; }
public FileOperationMessage(FileOperationType operationType, int numFilesCompleted, int numTotalFiles, string errorMessage) : base(MessageType.FileOperation) { if (numTotalFiles < numFilesCompleted) { throw new ArgumentException("numTotalFiles should not be less than numFilesCompleted"); } OperationType = operationType; NumFilesCompleted = numFilesCompleted; NumTotalFiles = numTotalFiles; ErrorMessage = errorMessage; }
public Task <int> Operation( FileOperationType operation, string systemPath, long position, int length, FileIOPriority priority, byte[] buffer, int bufferOffset, PriorityFileStream fs = null) { var op = new FileIOOperation { SystemPath = systemPath, Buffer = buffer, BufferOffset = bufferOffset, Position = position, Length = length, Operation = operation, TaskCompletionSource = new TaskCompletionSource <int>(), FileStream = fs }; switch (priority) { case FileIOPriority.Default: lock (_defaultQueue) _defaultQueue.Enqueue(op); break; case FileIOPriority.Background: lock (_backgroundQueue) _backgroundQueue.Enqueue(op); break; default: throw new ArgumentOutOfRangeException(nameof(priority), priority, null); } if (Interlocked.Increment(ref _activeOperations) <= FileIOScheduler.Instance.MaxConcurrentOperations) { StartNewReadTask(); } else { Interlocked.Decrement(ref _activeOperations); } return(op.TaskCompletionSource.Task); }
public FileOperation(string source, FileOperationType opType, long max_time = 0) { if (opType == FileOperationType.Move) { throw new ArgumentException("File Move Operation requires a destination path."); } this.type = opType; if (max_time > 0) { this.maxWaitTime = max_time; } this.sourcePath = source; }
public static bool CallSH(FileOperationType type, string[] from, string to, FileOperationFlags flags) { var fs = new SHFILEOPSTRUCT(); fs.wFunc = type; if (from.Length > 0) { fs.pFrom = string.Join("\0", from) + "\0\0"; } if (to.Length > 0) { fs.pTo = to + "\0\0"; } fs.fFlags = flags; return(SHFileOperation(ref fs) == 0); }
private static bool ShellOperation(FileOperationType operationType, FileOperationFlags operationFlags, string[] sources, string destination) { int num; SHFILEOPSTRUCT lpFileOp = GetShellOperationInfo(operationType, operationFlags, sources, destination); num = SafeNativeMethods.SHFileOperation(ref lpFileOp); SafeNativeMethods.SHChangeNotify(0x2381f, 3, IntPtr.Zero, IntPtr.Zero); if (lpFileOp.fAnyOperationsAborted) { return(false); } else if (num != 0) { Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } return(true); }
static bool CutCopy(string from, string to, FileOperationType foType) { try { var fs = new SHFILEOPSTRUCT { wFunc = foType, pFrom = from + '\0' + '\0', pTo = to + '\0' + '\0' }; SHFileOperation(ref fs); return(true); } catch (Exception) { return(false); } }
// Main overload for standard Move\Copy file(s) operation private static bool DoFileOperation(FileOperationType foType, string[] files, string destination) { try { var fs = new SHFILEOPSTRUCT { wFunc = foType, pFrom = string.Join("\0", files) + '\0' + '\0', pTo = destination + '\0' + '\0' }; SHFileOperation(ref fs); return(true); } catch (Exception) { return(false); } }
public static int FileOperation(string Path, FileOperationType OperationType, FileOperationFlags Flags) { try { var fs = new ShFileOpStruct { Func = OperationType, From = Path + '\0' + '\0', Flags = Flags }; return(SHFileOperation(ref fs)); } catch (Exception) { return(-1); } }
public void DomLoadedEventHandler(FileOperationType loadType) { switch (loadType) { case FileOperationType.Create: case FileOperationType.Open: if (_document != null) { _model.LoadNoteFields(); InitParameter(true); } break; case FileOperationType.Close: InitParameter(false); break; } }
public SUIFileException(string FileName, string Message, FileOperationType t, Exception e) : base(Message, e) { filePath = SUIUtil.getFilePathFromFileFullPath(FileName); if (filePath == null) { filePath = unknown; fileName = unknown; } else { fileName = SUIUtil.getFilePathFromFileFullPath(FileName); if (fileName == null) { fileName = unknown; } } operation = t; }
private string FormatLabel(FileOperationType type, int current, int max) { string typestr = ""; switch(type) { case FileOperationType.Copy: typestr = Catalog.GetString("Copying"); break; case FileOperationType.Move: typestr = Catalog.GetString("Moving"); break; case FileOperationType.Delete: typestr = Catalog.GetString("Deleting"); break; } if(max == 0) return string.Format(Catalog.GetString("{0} file/folder #{1}"), typestr, current); return string.Format(Catalog.GetPluralString("{0} {1} of {2} files/folders", "{0} file/folder", max), typestr, current, max); }
public void DomLoadedEventHandler(FileOperationType loadType) { switch (loadType) { case FileOperationType.Create: case FileOperationType.Open: if (_document != null) { if (_document.DocumentType == DocumentType.Library) { //TODO: } else { //TODO: } } break; } }
public void DomLoadedEventHandler(FileOperationType loadType) { IDocumentService doc = ServiceLocator.Current.GetInstance <IDocumentService>(); //close all page opened. _ListEventAggregator.GetEvent <ClosePageEvent>().Publish(Guid.Empty); //if loadType is Loaded, as follows SetOperationNode(RootNode); RootNode.Children.Clear(); switch (loadType) { case FileOperationType.Create: if (doc.Document != null) { RootNode.TreeNodeObject = doc.Document.DocumentSettings.LayoutSetting.MasterPageTree; _undoManager.Clear(); InitParameter(true); CreateDefaultMasters(); } break; case FileOperationType.Open: if (doc.Document != null) { RootNode.TreeNodeObject = doc.Document.DocumentSettings.LayoutSetting.MasterPageTree; LoadNodeViewModelFromTreeNodeObject(RootNode, RootNode.TreeNodeObject, true); InitParameter(true); _undoManager.Clear(); } break; case FileOperationType.Close: InitParameter(false); _undoManager.Clear(); break; } }
void DomLoadedEventHandler(FileOperationType loadType) { //close all page opened. _ListEventAggregator.GetEvent <ClosePageEvent>().Publish(Guid.Empty); //if loadType is Loaded, as follows SetOperationNode(RootNode); RootNode.Children.Clear(); switch (loadType) { case FileOperationType.Create: if (_document != null) { InitParameter(true); CreateDefaultPages(); _undoManager.Clear(); } break; case FileOperationType.Open: if (_document != null) { InitParameter(true); RootNode.UpdateDocument(_document); LoadNodeViewModelFromTreeNodeObject(RootNode, RootNode.TreeNodeObject); _undoManager.Clear(); } break; case FileOperationType.Close: InitParameter(false); _undoManager.Clear(); break; } }
private static void GilesAssemblyFileOperation(string testAssemblyFolder, FileOperationType fileOperationType) { var fileSystem = new FileSystem(); var filesToCopy = GetGilesAssembliesToUse(); var gilesTargetAssemblyFolder = Path.Combine(testAssemblyFolder, @"Giles"); if (!Directory.Exists(gilesTargetAssemblyFolder)) Directory.CreateDirectory(gilesTargetAssemblyFolder); filesToCopy.Each(f => { var sourcePath = f.Contains("\\") ? f : GetFileSourceLocation(f); var targetPath = Path.Combine(gilesTargetAssemblyFolder, fileSystem.GetFileName(f)); if (fileOperationType == FileOperationType.Copy || fileOperationType == FileOperationType.Delete) if (fileSystem.FileExists(targetPath)) fileSystem.DeleteFile(targetPath); if (fileOperationType == FileOperationType.Copy) { fileSystem.CopyFile(sourcePath, targetPath); } }); }
public void Modify(FileOperationType operationType, IEnumerable <IStorageItemWithPath> source, IEnumerable <IStorageItemWithPath> destination) { OperationType = operationType; Source = source; Destination = destination; }
public void Modify(FileOperationType operationType, IStorageItemWithPath source, IStorageItemWithPath destination) { OperationType = operationType; Source = source.CreateEnumerable(); Destination = destination.CreateEnumerable(); }
public FileOperation(FileOperationType type, string source, string destinationPath) { Type = type; SourceFilePath = source; DestinationPathFile = destinationPath; }
private static bool DoFileOperation(FileOperationType foType, string file, string destination) { return(DoFileOperation(foType, new[] { file }, destination)); }
public void Modify(FileOperationType operationType, IEnumerable <PathWithType> source, IEnumerable <PathWithType> destination) { OperationType = operationType; Source = source; Destination = destination; }
public SUIFileException(string FileName, string Message, FileOperationType t, Exception e):base(Message,e) { filePath = SUIUtil.getFilePathFromFileFullPath(FileName); if (filePath == null) { filePath = unknown; fileName = unknown; } else { fileName = SUIUtil.getFilePathFromFileFullPath(FileName); if (fileName == null) { fileName = unknown; } } operation = t; }
public SUIFileException(Exception innerException) : base(defaultMsg, innerException) { filePath = unknown; fileName = unknown; operation = FileOperationType.Unknown; }
/// <summary> /// Crée une nouvelle instance de FileOperationProgressEventArgs /// </summary> /// <param name="operationType">Type d'opération</param> /// <param name="source">Fichier source</param> /// <param name="destination">Fichier destination</param> /// <param name="transferredBytes">Nombre d'octets déjà transférés</param> /// <param name="totalBytes">Nombre total d'octets à transférer</param> public FileOperationProgressEventArgs( FileOperationType operationType, string source, string destination, long transferredBytes, long totalBytes) { OperationType = operationType; Source = source; Destination = destination; TransferredBytes = transferredBytes; TotalBytes = totalBytes; Action = FileOperationProgressAction.Continue; }
public StorageHistory(FileOperationType operationType, IEnumerable <PathWithType> source, IEnumerable <PathWithType> destination) { OperationType = operationType; Source = source; Destination = destination; }
public SUIFileException(string message, Exception innerException) : base(message, innerException) { filePath = unknown; fileName = unknown; operation = FileOperationType.Unknown; }
public StorageHistory(FileOperationType operationType, IList <IStorageItemWithPath> source, IList <IStorageItemWithPath> destination) { this.OperationType = operationType; this.Source = source; this.Destination = destination; }
public StorageHistory(FileOperationType operationType, IStorageItemWithPath source, IStorageItemWithPath destination) : this(operationType, source.CreateList(), destination.CreateList()) { }
public StorageHistory(FileOperationType operationType, PathWithType source, PathWithType destination) { OperationType = operationType; Source = source.CreateEnumerable(); Destination = destination.CreateEnumerable(); }
public StorageHistory(FileOperationType operationType, IStorageItemWithPath source, IStorageItemWithPath destination) { OperationType = operationType; Source = source.CreateList(); Destination = destination.CreateList(); }
public SUIFileException() : base(defaultMsg, null) { filePath = unknown; fileName = unknown; operation = FileOperationType.Unknown; }
/// <summary> /// Posts a new banner to the Status Center control for an operation. /// It may be used to return the progress, success, or failure of the respective operation. /// </summary> /// <param name="title">Reserved for success and error banners. Otherwise, pass an empty string for this argument.</param> /// <param name="message"></param> /// <param name="initialProgress"></param> /// <param name="status"></param> /// <param name="operation"></param> /// <returns>A StatusBanner object which may be used to track/update the progress of an operation.</returns> public PostedStatusBanner PostBanner(string title, string message, float initialProgress, ReturnResult status, FileOperationType operation) { StatusBanner item = new StatusBanner(message, title, initialProgress, status, operation); StatusBannersSource.Add(item); ProgressBannerPosted?.Invoke(this, EventArgs.Empty); return(new PostedStatusBanner(item)); }
public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) { if (m_destinationPath == null) { return; } var currentEditingGroup = editor.CurrentEditingGroup; EditorGUILayout.HelpBox("File Operation: Copy or Move Files.", MessageType.Info); editor.UpdateNodeName(node); GUILayout.Space(10f); var newOp = (FileOperationType)EditorGUILayout.EnumPopup("Operation", m_operationType); if (newOp != m_operationType) { using (new RecordUndoScope("Change Copy/Move Operation", node, true)) { m_operationType = newOp; onValueChanged(); } } var newDepth = EditorGUILayout.IntField("Removing Directory Depth", m_removingDirectoryDepth); if (newDepth != m_removingDirectoryDepth) { using (new RecordUndoScope("Change Directory Depth", node, true)) { m_removingDirectoryDepth = newDepth; onValueChanged(); } } GUILayout.Space(8f); //Show target configuration tab editor.DrawPlatformSelector(node); using (new EditorGUILayout.VerticalScope(GUI.skin.box)) { var disabledScope = editor.DrawOverrideTargetToggle(node, m_destinationPath.ContainsValueOf(currentEditingGroup), (bool enabled) => { using (new RecordUndoScope("Remove Target Directory Settings", node, true)){ if (enabled) { m_destinationPath[currentEditingGroup] = m_destinationPath.DefaultValue; m_destinationOption[currentEditingGroup] = m_destinationOption.DefaultValue; } else { m_destinationPath.Remove(currentEditingGroup); m_destinationOption.Remove(currentEditingGroup); } onValueChanged(); } }); using (disabledScope) { DestinationDirectoryOption opt = (DestinationDirectoryOption)m_destinationOption[currentEditingGroup]; var newOption = (DestinationDirectoryOption)EditorGUILayout.EnumPopup("Directory Option", opt); if (newOption != opt) { using (new RecordUndoScope("Change Directory Option", node, true)){ m_destinationOption[currentEditingGroup] = (int)newOption; onValueChanged(); } } EditorGUILayout.LabelField("Destination Path:"); string newDstPath = null; newDstPath = editor.DrawFolderSelector("", "Select Destination Folder", m_destinationPath[currentEditingGroup], GetDestinationPath(m_destinationPath[currentEditingGroup]), (string folderSelected) => { var projectPath = Directory.GetParent(Application.dataPath).ToString(); if (projectPath == folderSelected) { folderSelected = string.Empty; } else { var index = folderSelected.IndexOf(projectPath); if (index >= 0) { folderSelected = folderSelected.Substring(projectPath.Length + index); if (folderSelected.IndexOf('/') == 0) { folderSelected = folderSelected.Substring(1); } } } return(folderSelected); } ); if (newDstPath != m_destinationPath[currentEditingGroup]) { using (new RecordUndoScope("Change Destination Path", node, true)){ m_destinationPath[currentEditingGroup] = newDstPath; onValueChanged(); } } var exporterNodePath = GetDestinationPath(newDstPath); if (ValidateExportPath( newDstPath, exporterNodePath, () => { }, () => { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField(exporterNodePath + " does not exist."); if (GUILayout.Button("Create directory")) { Directory.CreateDirectory(exporterNodePath); } onValueChanged(); } EditorGUILayout.Space(); string parentDir = Path.GetDirectoryName(exporterNodePath); if (Directory.Exists(parentDir)) { EditorGUILayout.LabelField("Available Directories:"); string[] dirs = Directory.GetDirectories(parentDir); foreach (string s in dirs) { EditorGUILayout.LabelField(s); } } } )) { GUILayout.Space(10f); using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); if (GUILayout.Button(GUIHelper.RevealInFinderLabel)) { EditorUtility.RevealInFinder(exporterNodePath); } } } } } }
public DirectoryOperation(Group parent, String sourcePath, String destPath, FileOperationType operation) : base(parent, destPath) { SourceDirectory = sourcePath; Operation = operation; }
public void Modify(FileOperationType operationType, PathWithType source, PathWithType destination) { OperationType = operationType; Source = source.CreateEnumerable(); Destination = destination.CreateEnumerable(); }