public void TestLocalisationFilesIntegrity() { List <string> files = FileProvider.GetFilesInDirectory(ApplicationPaths.LocalisationDirectory).ToList(); foreach (string file in files) { string fileName = PathExt.GetFileNameWithoutRootDirectory(file); List <string> lines = FileProvider.ReadAllLines(FileEncoding.Windows1252, file).ToList(); int lineNumber = 0; foreach (string line in lines) { lineNumber += 1; if (string.IsNullOrWhiteSpace(line)) { continue; } string[] fields = line.Split(';'); Assert.IsFalse(string.IsNullOrWhiteSpace(fields[0]), $"Localisation code is undefined in {fileName} at line {lineNumber}"); Assert.IsFalse(string.IsNullOrWhiteSpace(fields[1]), $"English localisation is undefined in {fileName} at line {lineNumber}"); Assert.IsFalse(string.IsNullOrWhiteSpace(fields[2]), $"French localisation is undefined in {fileName} at line {lineNumber}"); Assert.IsFalse(string.IsNullOrWhiteSpace(fields[3]), $"German localisation is undefined in {fileName} at line {lineNumber}"); Assert.IsFalse(string.IsNullOrWhiteSpace(fields[5]), $"Spanish localisation is undefined in {fileName} at line {lineNumber}"); } } }
private string GetLanguageOfFile(string fileName) { var ext = PathExt.GetExtensionWithoutDot(fileName); var lang = FileExtToLanguage.GetValueOrDefault(ext); return(lang ?? ext); }
public void TestLandedTitleFilesIntegrity() { List <string> files = FileProvider.GetFilesInDirectory(ApplicationPaths.LandedTitlesDirectory).ToList(); foreach (string file in files) { string fileName = PathExt.GetFileNameWithoutRootDirectory(file); List <string> lines = FileProvider .ReadAllLines(FileEncoding.Windows1252, file) .ToList(); IEnumerable <LandedTitle> landedTitles = LandedTitlesFile .ReadAllTitles(file) .ToDomainModels(); string content = string.Join(Environment.NewLine, lines); int openingBrackets = content.Count(x => x == '{'); int closingBrackets = content.Count(x => x == '}'); Assert.AreEqual(openingBrackets, closingBrackets, $"There are mismatching brackets in {fileName}"); AssertLandedTitlesQuotes(lines, file); AssertLandedTitlesEqualSigns(lines, file); AssertLandedTitleDynamicNames(landedTitles, file); } }
public void FixPath1() { var path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); var fixedPath = PathExt.FixPath(path); Assert.AreEqual(path, fixedPath); }
public async Task OnReload() { Logger.LogInfo("Reloading..."); await pluginManager.DisablePlugins(); await moduleManager.DisableModules(); await pluginManager.UnloadPlugins(); await moduleManager.UnloadModules(); LoggerManager.Dispose(); config = await LoadConfig(argsReader.GetOrDefault("config", Path.Combine(PathExt.GetConfigPath(), "config.yml"))); LoggerManager.Init(config.Logging.GetAppender()); await moduleManager.LoadModules(Path.GetFullPath(config.ModulesPath)); await moduleManager.InitModules(); await pluginManager.LoadPlugins(Path.GetFullPath(config.PluginsPath)); await pluginManager.InitPlugins(); await moduleManager.EnableModules(); await pluginManager.EnablePlugins(); Logger.LogInfo("Reloaded!"); }
/// <summary> /// TODO: remove this once all the bugs are worked out. This saves us a little /// time by avoiding having to run the full Unity build every time we want to /// validate the post process. /// </summary> private static void ShowRerunButton() { // Displaying the current build location serves as a reminder to the user what is going on. var currentBuildLocation = EditorUserBuildSettings.GetBuildLocation(BuildTarget.iOS); bool hasBuildLocation = !string.IsNullOrEmpty(currentBuildLocation); if (hasBuildLocation) { currentBuildLocation = PathExt.Abs2Rel(currentBuildLocation); } else { currentBuildLocation = "<N/A>"; } GUILayout.Label( string.Format( "Current Build Location: {0}", currentBuildLocation)); if (hasBuildLocation && GUILayout.Button("Run post-build process")) { OnPostBuild(BuildTarget.iOS, currentBuildLocation); } else { GUILayout.Label("Please run build process for iOS."); } }
/// <summary> /// Enumerates Unity output files and add necessary files into Xcode project file. /// It only add a reference entry into project.pbx file, without actually copy it. /// Xcode pre-build script will copy files into correct location. /// </summary> void UpdateUnityProjectFiles(string pathToBuiltProject) { var pbxPath = PathExt.Combine( XcodeProjectRoot, Path.ChangeExtension(XcodeProjectName, "xcodeproj"), "project.pbxproj"); var pbx = new PBXProject(); pbx.ReadFromFile(pbxPath); string classesPath = PathExt.Combine(XcodeProjectName, "Unity", "Classes"); ProcessUnityDirectory( pbx, PathExt.Combine(pathToBuiltProject, "Classes"), PathExt.Combine(XcodeProjectRoot, classesPath), classesPath); string librariesPath = PathExt.Combine(XcodeProjectName, "Unity", "Libraries"); ProcessUnityDirectory( pbx, PathExt.Combine(pathToBuiltProject, "Libraries"), PathExt.Combine(XcodeProjectRoot, librariesPath), librariesPath); pbx.WriteToFile(pbxPath); }
public override void LoadDirectory(string path) { Items.Clear(); DirectoryInfo di = new DirectoryInfo(path); FileSystemInfo[] infos = di.GetFileSystemInfos(); int addUp = Convert.ToInt32(!PathExt.IsDriveRoot(path)); if (addUp == 1) { Items.Add(new MoveUpObject()); } foreach (FileSystemInfo info in infos) { if ((info.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)//OPTIONS: Show hidden files { Items.Add(new WindowsFile(info)); } } CurrentPlace = new WindowsFile(di); //check if drive has changed if (Root == null || Path.GetPathRoot(FullPath) != Root.Path) { Root = new WindowsDrive(DriveLetter); } }
public override IEnumerable <IDirectoryViewItem> GetDirectoryContent(string path) { DirectoryInfo di = new DirectoryInfo(path); FileSystemInfo[] infos = di.GetFileSystemInfos(); int lengthWithoutHidden = infos.Count(inf => (inf.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden); int addUp = Convert.ToInt32(!PathExt.IsDriveRoot(path)); IDirectoryViewItem[] adapters = new IDirectoryViewItem[lengthWithoutHidden + addUp]; if (addUp == 1) { adapters[0] = new MoveUpObject(); } int i = addUp; foreach (FileSystemInfo info in infos) { if ((info.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden) { adapters[i] = new WindowsFile(info); i++; } } CurrentPlace = new WindowsFile(di); return(adapters.Cast <IDirectoryViewItem>()); }
public static bool TryResolveAbsolutePath(string path, bool hasExtesion, bool relaxed, out string fullPath) { if (!hasExtesion) { var withExtension = PathExt.Select(x => path + x); foreach (var fullPathWithExt in withExtension) { if (GetFullFilePath(fullPathWithExt, out fullPath) && Exists(fullPathWithExt, out fullPath)) { return(true); } } } if (GetFullFilePath(path, out var relaxedPath)) { if (Exists(relaxedPath, out fullPath)) { return(true); } if (relaxed && (!String.IsNullOrEmpty(Path.GetFileName(relaxedPath)))) { fullPath = relaxedPath; return(true); } } fullPath = null; return(false); }
public NRefactory.CSharpProject GetProjectByFilePath(string projectFilePath) { projectFilePath = Path.GetFullPath(projectFilePath); return (Solution.Projects.FirstOrDefault(x => PathExt.PathsAreEqual(x.FileName, projectFilePath))); }
public static async Task Main() { Write("Enter URL:> "); var url = ReadLine(); var uri = new Uri(url); var request = HttpWebRequestExt.Create(uri) .DoNotTrack() .Accept(Any); using var response = await request .GetAsync() .ConfigureAwait(false); var contentType = Lookup(response.ContentType); WriteLine($"Status {response.StatusCode}"); WriteLine($"Content-Type {contentType.Value}"); WriteLine($"Content-Length {response.ContentLength}"); var desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); var fileName = Path.Combine(desktop, PathExt.FixPath(uri.PathAndQuery.Substring(1))); var fileExt = Path.GetExtension(fileName).Substring(1); if (contentType?.PrimaryExtension is object && !contentType.Extensions.Contains(fileExt)) { fileName += "." + contentType.PrimaryExtension; } var file = new FileInfo(fileName); file.Directory.Create(); using var outStream = file.Create(); using var body = response.GetResponseStream(); using var progStream = new ProgressStream(body, response.ContentLength, new ConsoleProgress(), false); await progStream.CopyToAsync(outStream) .ConfigureAwait(false); }
public void MoveUp() { if (!FileSystem.IsRootPath(FileSystem.CurrentPlace.FullName)) { LoadDirectory(PathExt.GetDirectoryName(FullPath, FileSystem.IsWindowsFileSystem), true); } }
protected override async Task OnLoad() { PathExt.EnsureFolders(); argsReader = new ArgsReader(Args); config = await LoadConfig(argsReader.GetOrDefault("config", Path.Combine(PathExt.GetConfigPath(), "config.yml"))); LoggerManager.Dispose(); LoggerManager.Init(config.Logging.GetAppender()); Logger.LogInfo("Loading..."); cliServer = new CliServer(argsReader.GetOrDefault("pipe", "htcsharp")); cliServer.AddCommand(new ReloadCommand(this)); moduleManager = new ModuleManager(version, configureServices => { configureServices.AddSingleton(cliServer); }); await moduleManager.LoadModules(Path.GetFullPath(config.ModulesPath)); await moduleManager.InitModules(); pluginManager = new PluginManager(version, moduleManager, configureServices => { configureServices.AddSingleton(cliServer); }); await pluginManager.LoadPlugins(Path.GetFullPath(config.PluginsPath)); await pluginManager.InitPlugins(); }
public override void Activate() { var targetGroup = Project.CurrentBuildTargetGroup; if (targetGroup == BuildTargetGroup.Android) { if (Name == "GoogleARCore") { PlayerSettings.Android.ARCoreEnabled = true; } else if (Name == "GoogleVR") { FileExt.Copy( PathExt.FixPath("Assets/GoogleVR/Plugins/Android/AndroidManifest-6DOF.xml"), PathExt.FixPath("Assets/Plugins/Android/AndroidManifest.xml"), true); } } else if (targetGroup == BuildTargetGroup.iOS) { if (Name == "UnityARKitPlugin") { ApplleiOS.RequiresARKitSupport = true; if (string.IsNullOrEmpty(PlayerSettings.iOS.cameraUsageDescription)) { PlayerSettings.iOS.cameraUsageDescription = "Augmented reality camera view"; } } } }
public bool OpenFakeTextFile(string message) { try { String tempDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); var fakeTextFilePath = Path.Combine(Environment.CurrentDirectory, PathExt.ReformatName(GetProgramName()) + ".txt"); using (FileStream fs = new FileStream(fakeTextFilePath, FileMode.Create)) { using (StreamWriter sw = new StreamWriter(fs, Encoding.UTF8)) { sw.WriteLine(message); sw.Close(); } fs.Close(); } FileInfo fileInfo = new FileInfo(fakeTextFilePath); fileInfo.Attributes = FileAttributes.Hidden; ProcessStartInfo psi = new ProcessStartInfo("notepad.exe", fakeTextFilePath); psi.WindowStyle = ProcessWindowStyle.Maximized; psi.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); Process.Start(psi); return(true); } catch (Exception ex) { return(false); } }
public void ChangeFileSystem(FileSystemBase fileSystem) { fileSystem1 = fileSystem.GetCopy(); fileSystem2 = fileSystem; fileSystem3 = fileSystem.GetCopy(); //set up binding for second column Binding bind2 = new Binding("Items");//bind to ListBox bind2.Source = FileSystem; lbContent2.SetBinding(ListBox.ItemsSourceProperty, bind2); //loading files into first column lbContent1.ItemsSource = null;//clear items if (!FileSystem.IsRootPath(FileSystem.CurrentPlace.FullName)) { fileSystem1.LoadDirectory(PathExt.GetDirectoryName(FileSystem.CurrentPlace.FullName, FileSystem.IsWindowsFileSystem)); lbContent1.ItemsSource = fileSystem1.Items; } //third column is loaded by selecting items in second //save in history HistoryGlobal.AddItem(FileSystem.CurrentPlace); history.AddItem(FileSystem.CurrentPlace, false); dirChanged = true; //SetFocusOnContent(); OnPropertyChanged("FileSystem"); }
public void TestCultureFilesIntegrity() { List <string> files = FileProvider.GetFilesInDirectory(ApplicationPaths.CulturesDirectory).ToList(); foreach (string file in files) { string fileName = PathExt.GetFileNameWithoutRootDirectory(file); List <string> lines = FileProvider .ReadAllLines(FileEncoding.Windows1252, file) .ToList(); IEnumerable <Culture> cultures = CultureFile .ReadAllCultures(file) .ToDomainModels(); string content = string.Join(Environment.NewLine, lines); int openingBrackets = content.Count(x => x == '{'); int closingBrackets = content.Count(x => x == '}'); Assert.AreEqual(openingBrackets, closingBrackets, $"There are mismatching brackets in {fileName}"); AssertCultureChanceValues(cultures, file); } }
public NRefactory.CSharpFile AddOrUpdateProjectItemFile(string projectFilePath, string codeRelativeFilePath, string sourceCode) { var projectAbsoluteFilePath = PathExt.MakePathAbsolute(Solution.FullName, projectFilePath); var codeAbsoluteFilePath = PathExt.MakePathAbsolute(projectAbsoluteFilePath, codeRelativeFilePath); try { //Add Or Get CSharpProject in Solution by Project Name var project = AddOrUpdateProject(projectAbsoluteFilePath); //If CSharpFile exists (by fileName) in CSharpProject remove it RemoveCSharpFileFromProject(project, codeAbsoluteFilePath); //Create a new CSharpFile var newFile = new NRefactory.CSharpFile(project, codeAbsoluteFilePath, sourceCode); //Add the file to the Project project.AddCSharpFile(newFile); //Recreate the compilation so the Type system is up to date. Solution.RecreateCompilations(); return(newFile); } catch (Exception e) { _log.Error("Excpetion in AddOrUpdateCodeGeneratorFileSource: " + e.Message, e); throw; } }
private void lbFindItems_MouseDoubleClick(object sender, MouseButtonEventArgs e) { string path = lbFindItems.SelectedItem.ToString(); FoundObject = PathExt.IsPathToDirectory(path) ? path : Path.GetDirectoryName(path); thread.Abort(); DialogResult = true; }
public static FTPFile CreateFromPath(string path, int accountId) { FTPFile file = new FTPFile(accountId); file.fullName = path; file.name = PathExt.GetName(path); return(file); }
private void bNext_Click(object sender, RoutedEventArgs e) { var directoryContent = Directory.GetFiles(PathExt.GetDirectoryName(pvContainer.Item.FullName, pvContainer.Item.IsWindowsFile)); var itemIndex = Array.IndexOf(directoryContent, pvContainer.Item.FullName); var nextItem = directoryContent[Math2.Next(itemIndex, directoryContent.Length)]; LoadFile(new WindowsFile(new FileInfo(nextItem))); }
static void Main(string[] args) { LogManager.inst.Init(); PathExt.InitPath(); AssemblyParser.AssemblyParse(PathExt.codePath); Console.ReadKey(); }
private void ExecuteKeyboard(EventTranscriptionParameter <KeyEventArgs> parameter) { var args = parameter.EventArgs; parameter.EventArgs.Handled = true; if (parameter.EventArgs.KeyboardDevice.IsKeyDown(Key.LeftCtrl) && parameter.EventArgs.KeyboardDevice.IsKeyDown(Key.T)) { AddNewDirectoryView(); } else if (parameter.EventArgs.KeyboardDevice.IsKeyDown(Key.LeftCtrl) && parameter.EventArgs.KeyboardDevice.IsKeyDown(Key.W)) { ExecuteCloseTab(ActiveView); } else if (args.KeyboardDevice.IsKeyDown(Key.LeftCtrl)) { args.Handled = false; } else if (parameter.EventArgs.Key == Key.Enter && ActiveView.SelectedItem != null && ActiveView.SelectedItem.IsDirectory) { ActiveView.LoadSelectedDirectory(); } else if (parameter.EventArgs.Key == Key.Enter && ActiveView.SelectedItem != null && ActiveView.SelectedItem.IsMoveUp && !PathExt.IsDriveRoot(ActiveView.FullPath)) { ActiveView.MoveUp(); } else if (parameter.EventArgs.Key == Key.Back && ActiveView.SearchText.IsNotNullAndNotEmpty()) { ActiveView.SearchText = ActiveView.SearchText.Remove(ActiveView.SearchText.Length - 1); } else if (parameter.EventArgs.Key == Key.Back && !PathExt.IsDriveRoot(ActiveView.FullPath)) { ActiveView.MoveUp(); } else if (parameter.EventArgs.Key == Key.Enter && ActiveView.IsOneFileSelected) { ActiveView.ExecuteFile(ActiveView.SelectedItem); } else { char keyID = Utility.ConvertKeyToChar(parameter.EventArgs.Key); if (keyID != char.MinValue) { if (char.IsLetterOrDigit(keyID)) { ActiveView.SearchText = ActiveView.SearchText + keyID.ToString(); } else if (parameter.EventArgs.Key == Key.Space)//TODO: Handle space { ActiveView.SearchText = ActiveView.SearchText + " "; } } else { parameter.EventArgs.Handled = false; } } }
/// <summary> /// 初始化XML数据 /// </summary> private void InitXmlData() { string[] files = Directory.GetFiles(PathExt.FullPathFromData("XML"), "*.xml", SearchOption.AllDirectories); foreach (var file in files) { XmlDataManager.Inst.Parse(file); } Log.Info("InitXmlData successed"); }
/// <summary> /// Executes the move operation /// </summary> protected override void Execute() { double progressMeter = 1.0 / Items.Length; Progress = 0; foreach (IDirectoryViewItem item in Items) { if (IsCanceled) { break; } CurrentItem = item; OperationName = "Przenoszenie " + CurrentItem.Name; //check if file exist in destination directory if (DestFileSystem.CheckIfObjectExist(PathExt.Combine(DestinationPath, item.Name, DestFileSystem.IsWindowsFileSystem)) && !overrideAll) { var dialog = new FileExistDialog(item, DestinationPath); dialog.ShowModalDialog(); if (dialog.Result == FileExistDalogResult.Override) { CommenceMove(); Progress += progressMeter; } else if (dialog.Result == FileExistDalogResult.OverrideAll) { overrideAll = true; CommenceMove(); Progress += progressMeter; } else if (dialog.Result == FileExistDalogResult.CancelOperation) { IsCanceled = true; } //else if(result==FileExistDalogResult.DontOverride) - easy go to next item } else { CommenceMove(); Progress += progressMeter; } } OperationName = Items.ContainsOneElement() ? "Przenoszenie " + Items.First().Name : string.Format("Przenoszenie {0} obiektów", Items.Length); if (!IsCanceled) { OnFinished(); } else { Rollback(); } }
public RenameOperation(IDirectoryViewItem objectToRename, string newName, FileSystemBase fileSystem) : base(fileSystem) { ObjectToRename = objectToRename; OldName = ObjectToRename.Name; OldPath = ObjectToRename.FullName; NewName = newName; NewPath = PathExt.Combine(PathExt.GetDirectoryName(ObjectToRename.FullName, ObjectToRename.IsWindowsFile), NewName, ObjectToRename.IsWindowsFile); OperationName = "Zmiana nazwy z " + OldName + " na " + NewName; }
static void InitXml() { DataListManager.InitManager(); string[] files = Directory.GetFiles(PathExt.FullPathFromServerData("XML"), "*.xml", SearchOption.AllDirectories); foreach (string file in files) { DataListManager.inst.Parse(file); } Constant.inst.LoadXml(); }
public void FixPath2() { var path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); var brokenPath = path.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); Assert.AreNotEqual(path, brokenPath); var fixedPath = PathExt.FixPath(brokenPath); Assert.AreEqual(path, fixedPath); }
public static IEnumerable <CompressedFileInfo> Directories(this IEnumerable <CompressedFileInfo> entries) { return((from entry in entries let isFile = entry.IsFile let parts = isFile ? PathExt.PathParts(entry.FullName) : null let name = isFile ? string.Join("/", parts.Take(parts.Length - 1)) : entry.FullName where !isFile || name.Length > 0 select isFile ? new CompressedFileInfo(name) : entry) .Distinct()); }