/// <summary> /// Handle a single or multipart rar file /// -Extract to the same folder if single volume /// -Moves the part.rar to the according extraction folder and triggers the extraction if archive is complete /// </summary> /// <param name="rarPath"></param> /// <param name="destDir"></param> /// <returns></returns> public bool HandleRarFile(string rarPath, out string destDir) { var archive = RarArchive.Open(rarPath); var isMultiPart = archive.IsMultipartVolume(); var isComplete = archive.IsComplete; logger.LogInformation("HandleRarFile [" + Path.GetFileName(rarPath) + "] " + (isMultiPart ? "MULTIPART" : "SINGLEPART")); destDir = GetArchiveExtractionDirectory(rarPath, isMultiPart); FilesystemHelper.CreateDirectory(destDir); logger.LogInformation("HandleRarFile: extraction directory is [" + destDir + "]"); // single rar file if (!isMultiPart && isComplete) { logger.LogInformation("HandleRarFile: extracting SINGLEPART"); return(ExtractArchive(archive, destDir)); } archive.Dispose(); // move part rar var movedPartArchivePath = Path.Combine(destDir, Path.GetFileName(rarPath)); FilesystemHelper.MoveOrReplace(rarPath, movedPartArchivePath); logger.LogInformation("HandleRarFile: moved " + Path.GetFileName(rarPath) + " to extraction directory"); logger.LogInformation("HandleRarFile: [" + destDir + "] : [" + string.Join(", ", Directory.GetFiles(destDir).Select(Path.GetFileName)) + "]"); // find first volume of same archive and ensure archive is complete archive = GetFirstVolume(destDir); if (archive == null) { logger.LogWarning("HandleRarFile: archive INCOMPLETE"); return(false); } logger.LogInformation("HandleRarFile: archive COMPLETE, starting extraction"); return(ExtractArchive(archive, destDir)); }
private void StartRecording() { if (!cameraLoaded || !cameraConnected || recording) { return; } string root; string subdir; if (index == 0) { root = PreferencesManager.CapturePreferences.CapturePathConfiguration.LeftVideoRoot; subdir = PreferencesManager.CapturePreferences.CapturePathConfiguration.LeftVideoSubdir; } else { root = PreferencesManager.CapturePreferences.CapturePathConfiguration.RightVideoRoot; subdir = PreferencesManager.CapturePreferences.CapturePathConfiguration.RightVideoSubdir; } string filenameWithoutExtension = view.CurrentVideoFilename; string extension = Filenamer.GetVideoFileExtension(); Dictionary <FilePatternContexts, string> context = BuildCaptureContext(); string path = Filenamer.GetFilePath(root, subdir, filenameWithoutExtension, extension, context); FilesystemHelper.CreateDirectory(path); if (!FilePathSanityCheck(path)) { return; } if (!OverwriteCheck(path)) { return; } if (consumerRecord.Active) { consumerRecord.Deactivate(); } if (recordingThumbnail != null) { recordingThumbnail.Dispose(); recordingThumbnail = null; } double interval = cameraGrabber.Framerate > 0 ? 1000.0 / cameraGrabber.Framerate : 40; SaveResult result = pipelineManager.StartRecord(path, interval); recording = result == SaveResult.Success; if (recording) { recordingStart = DateTime.Now; view.UpdateRecordingStatus(recording); view.Toast(ScreenManagerLang.Toast_StartRecord, 1000); } else { //DisplayError(result); } }
private void MakeSnapshot() { if (!cameraLoaded || consumerDisplay.Bitmap == null) { return; } string root; string subdir; if (index == 0) { root = PreferencesManager.CapturePreferences.CapturePathConfiguration.LeftImageRoot; subdir = PreferencesManager.CapturePreferences.CapturePathConfiguration.LeftImageSubdir; } else { root = PreferencesManager.CapturePreferences.CapturePathConfiguration.RightImageRoot; subdir = PreferencesManager.CapturePreferences.CapturePathConfiguration.RightImageSubdir; } string filenameWithoutExtension = view.CurrentImageFilename; string extension = Filenamer.GetImageFileExtension(); Dictionary <FilePatternContexts, string> context = BuildCaptureContext(); string path = Filenamer.GetFilePath(root, subdir, filenameWithoutExtension, extension, context); FilesystemHelper.CreateDirectory(path); if (!FilePathSanityCheck(path)) { return; } if (!OverwriteCheck(path)) { return; } //Actual save. Bitmap outputImage = BitmapHelper.Copy(consumerDisplay.Bitmap); if (outputImage == null) { return; } ImageHelper.Save(path, outputImage); view.Toast(ScreenManagerLang.Toast_ImageSaved, 750); // After save routines. NotificationCenter.RaiseRefreshFileExplorer(this, false); AddCapturedFile(path, outputImage, false); CaptureHistoryEntry entry = CreateHistoryEntrySnapshot(path); CaptureHistory.AddEntry(entry); if (index == 0) { PreferencesManager.CapturePreferences.CapturePathConfiguration.LeftImageFile = filenameWithoutExtension; } else { PreferencesManager.CapturePreferences.CapturePathConfiguration.RightImageFile = filenameWithoutExtension; } PreferencesManager.Save(); // Compute next name for user feedback. string next = Filenamer.ComputeNextFilename(filenameWithoutExtension); view.UpdateNextImageFilename(next); }