public static void Save() { if (Default == null || BaseDirectory.IsNullOrEmpty()) { return; } if (!Directory.Exists(BaseDirectory)) { Directory.CreateDirectory(BaseDirectory); } if (!Default.Password.IsNullOrEmpty()) { Default.Password = Convert.ToBase64String(Encoding.ASCII.GetBytes(Default.Password)); } try { // 設定をバックアップ File.Copy(Path.Combine(BaseDirectory, @"Preference.xml"), Path.Combine(BaseDirectory, @"Preference_backup.xml"), true); } catch { } using (var stream = File.Open(Path.Combine(BaseDirectory, @"Preference.xml"), FileMode.Create, FileAccess.Write, FileShare.None)) { Serializer <Settings> .Serialize(stream, Default); } }
/// <summary> /// Constructor. /// </summary> public CsvFileRepository( IConfigReader config, IFileSystemFacade fileSystemFacade) { _configReader = config; _fileSystemFacade = fileSystemFacade; _logger = LogManager.GetCurrentClassLogger(); BaseDirectory = _configReader.Settings.WorkingDirectoryBase; if (string.IsNullOrWhiteSpace(BaseDirectory) || string.Equals(BaseDirectory.ToLower(), "desktop")) { BaseDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); } WorkingDirectory = Path.Combine(BaseDirectory, _configReader.Settings.WorkingDirectory); BackupDirectory = Path.Combine(WorkingDirectory, _configReader.Settings.BackupDirectory); _separator = _configReader.Settings.CsvSeparator; _dateFormat = _configReader.Settings.DateFormatForFileName; _fileNameExtension = _configReader.Settings.CsvFileNameExtension; _cultureInfo = new CultureInfo(_configReader.Settings.CultureInfo); _logger.Debug($"Base directory is {BaseDirectory} from config file."); _logger.Debug($"Working directory is {WorkingDirectory} from config file."); _logger.Debug($"Backup directory is {BackupDirectory} from config file."); _logger.Debug($"File name for file writing is {_fileName} from config file."); _logger.Debug($"File name extension is {_fileNameExtension} from config file."); _logger.Debug($"Culture info for file writing is {_cultureInfo} from config file."); _logger.Debug($"CSV separator is {_separator} from config file."); }
public void Update(IEnumerable <int> Changelists, TextWriter Log) { int MinChangelist = Changelists.Min(); int MaxChangelist = Changelists.Max(); Builds = new Dictionary <int, List <BuildUserMetadata> >(); foreach (DirectoryInfo BaseDirectory in EnumerateMetadataDirectories(RootFolder, MinChangelist, MaxChangelist)) { foreach (FileInfo FileInfo in BaseDirectory.EnumerateFiles("*.txt")) { int Changelist; if (ParseChangelistFromFileName(FileInfo.Name, out Changelist) && Changelist >= MinChangelist && Changelist <= MaxChangelist) { BuildUserMetadata Metadata; if (CacheMetadata(FileInfo, out Metadata, Log)) { List <BuildUserMetadata> UserMetadataList; if (!Builds.TryGetValue(Changelist, out UserMetadataList)) { UserMetadataList = new List <BuildUserMetadata>(); Builds.Add(Changelist, UserMetadataList); } UserMetadataList.Add(Metadata); } } } } }
public override IEnumerable <string> GetSourcePaths(ConfigurationSelector sel) { var dirs = new List <string>(); List <DubBuildSetting> l; string d; bool returnedOneItem = false; foreach (var sett in GetBuildSettings(sel)) { if (sett.TryGetValue(DubBuildSettings.SourcePathsProperty, out l)) { returnedOneItem = true; foreach (var setting in l) { foreach (var directory in setting.Values) { d = ProjectBuilder.EnsureCorrectPathSeparators(directory); if (!Path.IsPathRooted(d)) { if (this is DubSubPackage) { (this as DubSubPackage).useOriginalBasePath = true; } d = Path.GetFullPath(Path.Combine(BaseDirectory.ToString(), d)); if (this is DubSubPackage) { (this as DubSubPackage).useOriginalBasePath = false; } } // Ignore os/arch/version constraints for now if (dirs.Contains(d) || !Directory.Exists(d)) { continue; } dirs.Add(d); } } } } if (!returnedOneItem) { d = BaseDirectory.Combine("source").ToString(); if (Directory.Exists(d)) { dirs.Add(d); } d = BaseDirectory.Combine("src").ToString(); if (Directory.Exists(d)) { dirs.Add(d); } } return(dirs); }
protected override Task OnExecute(ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration) { return(Task.Factory.StartNew(async() => { ExternalConsole console = context.ExternalConsoleFactory.CreateConsole(false, monitor.CancellationToken); string targetName = ""; foreach (var target in fileFormat.Targets.Values) { if (target.Type == CMakeTarget.Types.Binary) { targetName = target.Name; break; } } if (string.IsNullOrEmpty(targetName)) { monitor.ReportError("Can't find an executable target."); return; } FilePath f = BaseDirectory.Combine(outputDirectory); NativeExecutionCommand cmd; if (File.Exists(f.Combine(targetName))) { cmd = new NativeExecutionCommand(f.Combine(targetName)); } else if (File.Exists(f.Combine(string.Format("{0}.{1}", targetName, "exe")))) { cmd = new NativeExecutionCommand(f.Combine(string.Format("{0}.{1}", targetName, "exe"))); } else if (File.Exists(f.Combine("./Debug", targetName))) { cmd = new NativeExecutionCommand(f.Combine("./Debug", targetName)); } else if (File.Exists(f.Combine("./Debug", string.Format("{0}.{1}", targetName, "exe")))) { cmd = new NativeExecutionCommand(f.Combine("./Debug", string.Format("{0}.{1}", targetName, "exe"))); } else { monitor.ReportError("Can't determine executable path."); return; } try { var handler = Runtime.ProcessService.GetDefaultExecutionHandler(cmd); var op = handler.Execute(cmd, console); using (var t = monitor.CancellationToken.Register(op.Cancel)) await op.Task; monitor.Log.WriteLine("The operation exited with code: {0}", op.ExitCode); } catch (Exception ex) { monitor.ReportError("Can't execute the target.", ex); } finally { console.Dispose(); } })); }
public void UpdateLocalIncludeCache() { DCompilerConfiguration.UpdateParseCacheAsync(LocalIncludes, BaseDirectory, ParentSolution == null ? BaseDirectory.ToString() : ParentSolution.BaseDirectory.ToString(), true, LocalIncludeCache_FinishedParsing); }
public override SolutionItemConfiguration CreateConfiguration(string name) { var conf = new AspNetAppProjectConfiguration(name); conf.CopyFrom(base.CreateConfiguration(name)); conf.OutputDirectory = BaseDirectory.IsNullOrEmpty? "bin" : (string)BaseDirectory.Combine("bin"); return(conf); }
public AESenderViewModel() { encryptCommand = new DelegateCommand(Encrypt); chooseFileCommand = new DelegateCommand(ChooseFile); baseDirectory = BaseDirectory.GetBaseDirectory(); FileChoice = baseDirectory + fileName; }
protected override bool CanHandleDeviceCommand(DeviceCommand command) { try { SafeUri uri = new SafeUri(command.DeviceId); return(BaseDirectory.StartsWith(uri.LocalPath)); } catch { return(false); } }
public override void ActivateOptions() { base.ActivateOptions(); if (SecurityContext == null) { SecurityContext = SecurityContextProvider.DefaultProvider.CreateSecurityContext(this); } using (SecurityContext.Impersonate(this)) BaseDirectory = ConvertToFullPath(BaseDirectory.Trim()); }
public ProjectFile GetInfoPlist () { var name = BaseDirectory.Combine ("Info.plist"); var pf = Files.GetFile (name); if (pf != null) return pf; var doc = new PlistDocument (); doc.Root = new PlistDictionary (); doc.WriteToFile (name); return AddFile (name); }
/// <summary> /// renames the current folder (move) /// </summary> /// <param name="newName"></param> public string RenameDirectory(string newName) { string newPath = System.IO.Path.Combine(_baseDirectory.Parent.FullName, newName); BaseDirectory.MoveTo(newPath); // reset some information to be up2date _baseDirectory = new DirectoryInfo(newPath); _files = null; return(newPath); }
public override bool SetComponent(string component) { var(componentDirectoryFound, componentDirectory) = BaseDirectory.TryNavigateDirectoryDown(component); if (!componentDirectoryFound) { return(false); } Component = component; BaseDirectory = componentDirectory; return(true); }
public override int GetHashCode() { unchecked { int hashCode = (File != null ? File.GetHashCode() : 0); hashCode = (hashCode * 397) ^ ParsedSuccessfully.GetHashCode(); hashCode = (hashCode * 397) ^ LastWriteTime.GetHashCode(); hashCode = (hashCode * 397) ^ (BaseDirectory != null ? BaseDirectory.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Types != null ? Types.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Includes != null ? Includes.GetHashCode() : 0); return(hashCode); } }
ProjectFile GetWebConfig() { var webConf = BaseDirectory.Combine("web.config"); foreach (var file in Files) { if (string.Compare(file.FilePath.ToString(), webConf, StringComparison.OrdinalIgnoreCase) == 0) { return(file); } } return(null); }
/// <summary> /// creates the sub folder at the root level /// </summary> /// <param name="newName"></param> public void MoveAllSubElements(DirectoryInfo newPath) { // move all files foreach (FileInfo subFile in BaseDirectory.GetFiles("*", SearchOption.TopDirectoryOnly)) { subFile.MoveTo(System.IO.Path.Combine(newPath.FullName, subFile.Name)); } // move all folders foreach (DirectoryInfo subDir in BaseDirectory.GetDirectories("*", SearchOption.TopDirectoryOnly)) { subDir.MoveTo(System.IO.Path.Combine(newPath.FullName, subDir.Name)); } }
protected override Task <BuildResult> OnClean(ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext buildSession) { return(Task.Factory.StartNew(() => { var results = new BuildResult(); FilePath path = BaseDirectory.Combine(outputDirectory); if (Directory.Exists(path)) { FileService.DeleteDirectory(path); } return results; })); }
public FTSBase(AppSettings appSettings) { analyzer = new StandardAnalyzer(this.Version); //analyzer = new Lucene.Net.Analysis.En.EnglishAnalyzer(this.Version); //indexDirectory = FSDirectory.Open(new DirectoryInfo(appSettings.IndexPath)); indexDirectory = NCacheDirectory.Open(appSettings.LuceneCacheName, appSettings.IndexPath); //--- Create the configuration for IndexWriter indexWriterConfig = new IndexWriterConfig(this.Version, analyzer); if (indexWriter == null) { indexWriter = new IndexWriter(indexDirectory, indexWriterConfig); } }
public IEnumerable <string> GetSourcePaths(List <DubBuildSettings> settings) { string d; List <DubBuildSetting> l; bool returnedOneItem = false; foreach (var sett in settings) { if (sett.TryGetValue(DubBuildSettings.SourcePathsProperty, out l)) { for (int i = l.Count - 1; i >= 0; i--) // Ignore architecture/os/compiler restrictions for now { for (int j = l[i].Flags.Length - 1; j >= 0; j--) { d = l[i].Flags[j]; if (!Path.IsPathRooted(d)) { d = BaseDirectory.Combine(d).ToString(); } if (!Directory.Exists(d)) { continue; } returnedOneItem = true; } } } } if (returnedOneItem) { yield break; } d = BaseDirectory.Combine("source").ToString(); if (Directory.Exists(d)) { yield return(d); } d = BaseDirectory.Combine("src").ToString(); if (Directory.Exists(d)) { yield return(d); } }
protected override void OnSaved(SolutionItemEventArgs args) { base.OnSaved(args); if (ExtendedConfiguration != null) { try { var json = JsonConvert.SerializeObject(ExtendedConfiguration, Newtonsoft.Json.Formatting.Indented); File.WriteAllText(BaseDirectory.Combine(ConfigJson), json); } catch { } } }
/// <summary> /// Updates the project's parse cache and reparses all of its D sources /// </summary> public void UpdateParseCache() { analysisFinished_LocalCache = analysisFinished_FileLinks = false; var hasFileLinks = new List <ProjectFile>(); foreach (var f in Files) { if ((f.IsLink || f.IsExternalToProject) && File.Exists(f.ToString())) { hasFileLinks.Add(f); } } // To prevent race condition bugs, test if links exist _before_ the actual local file parse procedure starts. if (hasFileLinks.Count == 0) { analysisFinished_FileLinks = true; } LocalFileCache.BeginParse(new[] { BaseDirectory.ToString() }, BaseDirectory); /* * Since we don't want to include all link files' directories for performance reasons, * parse them separately and let the entire reparsing procedure wait for them to be successfully parsed. * Ufcs completion preparation will be done afterwards in the TryBuildUfcsCache() method. */ if (hasFileLinks.Count != 0) { new System.Threading.Thread((object o) => { foreach (var f in (List <ProjectFile>)o) { var mod = DParser.ParseFile(f.FilePath) as DModule; var modName = f.ProjectVirtualPath.ToString().Replace(Path.DirectorySeparatorChar, '.'); _filelinkModulesToInsert.Add(mod); } analysisFinished_FileLinks = true; _InsertFileLinkModulesIntoLocalCache(); TryBuildUfcsCache(); }) { IsBackground = true } }
public static bool ViewPathContains(string innerPath) { var currentPath = innerPath; while (currentPath != null && !Path.GetFullPath(currentPath).Trim('\\').Equals(Path.GetPathRoot(currentPath), StringComparison.InvariantCultureIgnoreCase)) { if (Path.GetFullPath(currentPath).Trim('\\').Equals(BaseDirectory.Trim('\\'), StringComparison.InvariantCultureIgnoreCase)) { return(true); } currentPath = Path.GetDirectoryName(currentPath); } return(false); }
/// <summary> /// If the dmd bin directory contains a 'dmd' or 'dmd2', /// check if phobos and/or core paths are existing, /// and add them to the ASTCache /// OR empirically update the directory paths /// </summary> public void TryAddImportPaths(bool UpdateOldPaths = true) { var defaultDmdDirname = Version == DVersion.D2? "dmd2":"dmd"; int k = BaseDirectory.IndexOf(defaultDmdDirname + '\\'); if (k > 0) { var dmdPath = BaseDirectory.Substring(0, k + defaultDmdDirname.Length); var dirs = new[] { @"src\phobos", @"src\druntime\import" }; bool DirAdded = false; // Check for phobos on both D1 and D2 foreach (var subPath in dirs) { var dir = Path.Combine(dmdPath, subPath); var wasUpdated = false; if (UpdateOldPaths && ASTCache.ParsedDirectories != null) { foreach (var pdir in ASTCache.ParsedDirectories.ToArray()) { if (wasUpdated = pdir.Contains(Path.Combine(defaultDmdDirname, subPath))) { ASTCache.ParsedDirectories.Remove(pdir); ASTCache.ParsedDirectories.Add(dir); } } } if (!wasUpdated && !ASTCache.ParsedDirectories.Contains(dir) && Directory.Exists(dir)) { DirAdded = true; ASTCache.ParsedDirectories.Add(dir); } } if (DirAdded) { ASTCache.BeginParse(); } } }
public MainWindow() : base(Gtk.WindowType.Toplevel) { Build(); girBrowseButton.Clicked += girBrowseButton_Clicked; girLoadButton.Clicked += girLoadButton_Clicked; girTreeView.AppendColumn("Element", new CellRendererText(), "text", 0, "foreground", 3, "strikethrough", 4); girTreeView.AppendColumn("N", new CellRendererText(), "text", 2, "foreground", 3, "strikethrough", 4); girTreeView.AppendColumn("Name", new CellRendererText(), "text", 1, "foreground", 3, "strikethrough", 4); girTreeView.Selection.Changed += girTreeView_Selection_Changed; girAttrNodeView.NodeStore = new NodeStore(typeof(AttributeNode)); girAttrNodeView.AppendColumn("Attribute", new CellRendererText(), "text", 0); girAttrNodeView.AppendColumn("Value", new CellRendererText(), "text", 1); fixupBrowseButton.Clicked += fixupBrowseButton_Clicked; fixupApplyButton.Clicked += fixupApplyButton_Clicked; fixupTreeView.AppendColumn("Element", new CellRendererText(), "text", 0, "foreground", 3, "strikethrough", 4); fixupTreeView.AppendColumn("N", new CellRendererText(), "text", 2, "foreground", 3, "strikethrough", 4); fixupTreeView.AppendColumn("Name", new CellRendererText(), "text", 1, "foreground", 3, "strikethrough", 4); fixupTreeView.Selection.Changed += fixupTreeView_Selection_Changed; fixupAttrNodeView.NodeStore = new NodeStore(typeof(AttributeNode)); fixupAttrNodeView.AppendColumn("Attribute", new CellRendererText(), "text", 0); fixupAttrNodeView.AppendColumn("Value", new CellRendererText(), "text", 1); #if DEBUG girFileNameEntry.Text = BaseDirectory.FindDataFile( System.IO.Path.Combine("gir-1.0", "Gio-2.0.gir")) ?? ""; fixupFileNameEntry.Text = "../../../Gio-2.0/Gio-2.0.girfixup"; girLoadButton.Click(); #endif }
protected override void OnEndLoad() { var configJson = BaseDirectory.Combine(ConfigJson); if (File.Exists(configJson)) { try { var contents = File.ReadAllText(configJson); ExtendedConfiguration = JsonConvert.DeserializeObject <ExtendedProjectConfig>(contents); } catch { } } base.OnEndLoad(); }
protected override void OnItemsAdded(System.Collections.Generic.IEnumerable <ProjectItem> objs) { foreach (ProjectItem obj in objs) { if (obj is NestedContentProject) { NestedContentProject contentProject = obj as NestedContentProject; FilePath contentProjectPath = BaseDirectory.Combine(contentProject.Include); if (File.Exists(contentProjectPath)) { contentProject.Project = (ContentProject)ContentProject.LoadProject(contentProjectPath, new SimpleProgressMonitor()); RegisterInternalChild(contentProject.Project); } } } base.OnItemsAdded(objs); }
public override FilePath GetOutputFileName(ConfigurationSelector configuration) { var cfg = GetConfiguration(configuration) as DubProjectConfiguration; string targetPath = null, targetName = null, targetType = null; CommonBuildSettings.TryGetTargetFileProperties(this, configuration, ref targetType, ref targetName, ref targetPath); if (cfg != null) { cfg.BuildSettings.TryGetTargetFileProperties(this, configuration, ref targetType, ref targetName, ref targetPath); } if (string.IsNullOrWhiteSpace(targetPath)) { targetPath = BaseDirectory.ToString(); } else if (!Path.IsPathRooted(targetPath)) { targetPath = BaseDirectory.Combine(targetPath).ToString(); } if (string.IsNullOrWhiteSpace(targetName)) { var packName = packageName.Split(':'); targetName = packName[packName.Length - 1]; } if (string.IsNullOrWhiteSpace(targetType) || (targetType = targetType.ToLowerInvariant()) == "executable" || targetType == "autodetect") { if (OS.IsWindows) { targetName += ".exe"; } } else { //TODO } return(Path.Combine(targetPath, targetName)); }
FilePath GetProjectJsonFileName() { ProjectFile projectJsonFile = Items.OfType <ProjectFile> () .FirstOrDefault(projectFile => IsProjectJsonFile(projectFile.FilePath)); if (projectJsonFile != null) { return(projectJsonFile.FilePath); } FilePath projectJsonFileName = BaseDirectory.Combine("project.json"); if (File.Exists(projectJsonFileName)) { return(projectJsonFileName); } return(null); }
private IEnumerable <System.Reflection.Assembly> GetAssembly() { var assemblies = new List <System.Reflection.Assembly>(); BaseDirectory.Create(); if (BaseDirectory.Exists()) { var files = BaseDirectory.GetFiles("*.dll"); foreach (var file in files) { assemblies.Add(CustomAssembly.LoadFile(file.FullName)); } return(assemblies); } else { throw new DirectoryException($"BaseDirectory from path \"{BaseDirectory}\" is not exist"); } }
public RSAXML(string path = ".") { baseDirectory = BaseDirectory.GetBaseDirectoryWinFormat(); dirpaths = new string[] { baseDirectory + path + pubpath, path + pubpath, }; filepaths = new string[] { baseDirectory + path + pubpath + pubname, path + pubpath + pubname, }; if (Modulus is null) //Dumb check because I added the option to manually insert public key data later { GetKey(baseDirectory + path); } }