private string GetDirectory(string input) { if (_fileSystemManager.DirectoryExists(input)) { return(input); } return(GetNearestDirectory(input)); }
public void ShouldGetFilesAndFolders() { using (_mockRepository.Record()) { Expect.Call(_fileSystemManagerMock.DirectoryExists(SomeFolder)).Return(true); Expect.Call(_fileSystemManagerMock.FileAndFolderNamesIn(SomeFolder, string.Empty)).Repeat.Once() .Return(SomeFileAndFolders); } using (_mockRepository.Playback()) { _provider = new FileSystemAutoCompleteProvider(_fileSystemManagerMock); var suggestions = _provider.GetSuggestionsFor(SomeFolder); CollectionAssert.AreEqual(SomeFileAndFolders, suggestions); } }
protected override void DoValidate() { var folder = Model.CurrentProfile.DestinationSettings.Folder; if (string.IsNullOrEmpty(folder) || !_fileSystemManager.DirectoryExists(folder)) { throw new WizardStepException("Destination " + folder + " does not exist"); } }
/// <summary> /// Attempts to read the game folder and determine whether the game is running on a 64 or 32-bit system. /// Based on that, sets the 'bin_folder' property in the configuration file. /// </summary> public void DetermineSystemType() { if (!_fileSystemManager.DirectoryExists(_configurationManager.UserConfig.GamePath)) { return; } if (_fileSystemManager.DirectoryExists(_configurationManager.UserConfig.GamePath + "\\bin64")) { _configurationManager.UserConfig.BinFolder = "bin64"; _configurationManager.UserConfig.ExeName = "Gw2-64.exe"; } else if (_fileSystemManager.DirectoryExists(_configurationManager.UserConfig.GamePath + "\\bin")) { _configurationManager.UserConfig.BinFolder = "bin"; _configurationManager.UserConfig.ExeName = "Gw2.exe"; } _configurationManager.SaveConfiguration(); }
private void CreateDatabaseFile() { var localDatabaseDirectory = _fileSystemManager.GetDirectoryName(_environmentSettingsProvider.LocalDatabasePath); if (!_fileSystemManager.DirectoryExists(localDatabaseDirectory)) { _fileSystemManager.CreateDirectory(localDatabaseDirectory); } using (var fileStream = _fileSystemManager.CreateFile(_environmentSettingsProvider.LocalDatabasePath)) fileStream.Flush(); }
protected override void DoValidate() { var settings = Model.CurrentProfile.DeployStatusSettings; if (!settings.Skip) { var folder = settings.Folder; if (string.IsNullOrEmpty(folder) || !_fileSystemManager.DirectoryExists(folder)) { throw new WizardStepException("Deploy status folder " + folder + " does not exist"); } } }
protected override DeploymentStepStatus DoExecute() { if (_fileSystemManager.DirectoryExists(Parameters.TempDirectoryPath)) { var tempDirectory = new DirectoryInfo(Parameters.TempDirectoryPath); Status.AppendDetailsLine("Removing tempdir " + tempDirectory.FullName); _fileSystemManager.DeleteDirectory(tempDirectory); } else { Status.AppendDetailsLine(Parameters.TempDirectoryPath + " does not exitst. Nothing to remove."); } return(Status); }
/// <summary> /// Deletes all addons, addon loader, and configuration data related to addons. /// </summary> public void DeleteAllAddons() { //set installed, disabled, default, and version collections to the default installation setting _configurationManager.UserConfig.AddonsList = new AddonsList(); //clear loader_version _configurationManager.UserConfig.LoaderVersion = null; //delete disabled plugins folder: ${install dir}/disabled plugins if (_fileSystemManager.DirectoryExists("Disabled Plugins")) _fileSystemManager.DirectoryDelete("Disabled Plugins", true); //delete addons: {game folder}/addons if (_fileSystemManager.DirectoryExists( _fileSystemManager.PathCombine(_configurationManager.UserConfig.GamePath, "addons"))) _fileSystemManager.DirectoryDelete( _fileSystemManager.PathCombine(_configurationManager.UserConfig.GamePath, "addons"), true); //delete addon loader: {game folder}/{bin/64}/d3d9.dll _fileSystemManager.FileDelete(_fileSystemManager.PathCombine( _fileSystemManager.PathCombine(_configurationManager.UserConfig.GamePath, _configurationManager.UserConfig.BinFolder), "d3d9.dll")); //write cleaned config file _configurationManager.SaveConfiguration(); }
public bool Move(DiskOprationInfo moveInfo) { //if (moveInfo.DestinationPath[0] != '~') // moveInfo.DestinationPath = moveInfo.DestinationPath[0] == '/' ? "~" + moveInfo.DestinationPath : "~/" + moveInfo.DestinationPath; //if (moveInfo.SourcePath[0] != '~') // moveInfo.SourcePath = moveInfo.SourcePath[0] == '/' ? "~" + moveInfo.SourcePath : "~/" + moveInfo.SourcePath; var rootPath = HostingEnvironment.ApplicationHost.GetPhysicalPath(); var tempPath = _fileSystemManager.RelativeToAbsolutePath(Config.ThumbnailPath); if (tempPath == null) { throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.PathNotFound, Config.ThumbnailPath)); } var thumbnailRootPath = tempPath.ToLower(); var destinationPath = AuthorizeManager.AuthorizeActionOnPath(moveInfo.DestinationPath, ActionKey.WriteToDisk); var sourcePath = AuthorizeManager.AuthorizeActionOnPath(moveInfo.SourcePath, ActionKey.ReadFromDisk); Parallel.ForEach(moveInfo.Files, file => { var source = _fileSystemManager.RelativeToAbsolutePath(sourcePath + "/" + file); var dist = _fileSystemManager.RelativeToAbsolutePath(destinationPath + "/" + file); if (source == null) { throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.PathNotFound, "source")); } if (dist == null) { throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.PathNotFound, "dist")); } _fileSystemManager.MoveFile(source, dist); var thumbnailSourcePath = source.Substring(rootPath.Length); var thumbnailDistPath = dist.Substring(rootPath.Length); if (_fileSystemManager.FileExist(thumbnailRootPath + thumbnailSourcePath)) { _fileSystemManager.MoveFile(thumbnailRootPath + thumbnailSourcePath, thumbnailRootPath + thumbnailDistPath); } }); Parallel.ForEach(moveInfo.Folders, folder => { var source = _fileSystemManager.RelativeToAbsolutePath(sourcePath + "/" + folder); var dist = _fileSystemManager.RelativeToAbsolutePath(destinationPath + "/" + folder); if (source == null) { throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.PathNotFound, "source")); } if (dist == null) { throw new KhodkarInvalidException(LanguageManager.ToAsErrorMessage(ExceptionKey.PathNotFound, "dist")); } _fileSystemManager.MoveDirectory(source, dist); var thumbnailSourcePath = source.Substring(rootPath.Length); var thumbnailDistPath = dist.Substring(rootPath.Length); if (_fileSystemManager.DirectoryExists(thumbnailRootPath + thumbnailSourcePath)) { _fileSystemManager.MoveDirectory(thumbnailRootPath + thumbnailSourcePath, thumbnailRootPath + thumbnailDistPath); } }); return(true); }