static Tests() { BuildServerDetector.Detected = false; DiffRunner.Disabled = false; DiffTools.AddTool( name: "MyTools", autoRefresh: true, isMdi: false, supportsText: true, requiresTarget: true, arguments: (path1, path2) => $"\"{path1}\" \"{path2}\"", exePath: diffToolPath, binaryExtensions: new[] { "knownBin" }); var binPath = AllFiles.Files["jpg"]; var newPath = Path.ChangeExtension(binPath.Path, "knownBin"); File.Copy(binPath.Path, newPath, true); AllFiles.UseFile(Category.Image, newPath); VerifierSettings.RegisterFileConverter <TypeToSplit>( (split, _) => new ConversionResult( split.Info, new List <Target> { new("txt", split.Property1), new("txt", split.Property2) }));
static void Main(string[] args) { var path = $@"F:\Clients\MuhraSoft\MuhraSoftSystemV1Store\MuhraSoftSystem - Temp\MuhraSoftSystem\MuhraSoftSystem.csproj"; var filename = $@"{path}\MuhraSoftSystem.csproj"; XDocument doc = XDocument.Load(filename); XNamespace ns = "http://schemas.microsoft.com/developer/msbuild/2003"; void DumpMatches(IEnumerable <string> values) { foreach (string x in values) { AllFiles.Add(x); } } DumpMatches(doc.Descendants(ns + "Compile").Select(x => x.Attribute("Include").Value)); DumpMatches(doc.Descendants(ns + "AssemblyOriginatorKeyFile").Select(x => x.Value)); var dirInfo = new DirectoryInfo(path); var allFilesOnDisk = dirInfo.GetFiles("*.*", SearchOption.AllDirectories).Select(s => s.FullName).ToList(); var allFilesFromProjectFile = AllFiles.Select(s => $@"{path}\MuhraSoftSystem\{s}").ToList(); var excludedFiles = allFilesOnDisk.Except(allFilesFromProjectFile).ToList(); var ff = excludedFiles.Where(w => w.Contains("All2") && w.EndsWith(".cs")).ToList(); foreach (var f in ff) { if (f.EndsWith(".cs")) { File.Delete(f); Debug.WriteLine(f); } } }
/// <summary> /// Refreshes the current view of files /// </summary> /// <param name="allFiles">Clears down all files to be refreshed</param> public void Refresh(bool allFiles) { if (CurrentFileList != null) { CurrentFileList.Clear(); } if (allFiles) { if (AllFiles != null) { AllFiles.Clear(); } SelectedFile = null; } if (SelectedFile == null) { OnLoadData(); } else { SelectedFile.Children = null; ExpandFile(SelectedFile); } }
static Tests() { BuildServerDetector.Detected = false; DiffTools.AddTool( name: "MyTools", autoRefresh: true, isMdi: false, supportsText: true, requiresTarget: true, arguments: (path1, path2) => $"\"{path1}\" \"{path2}\"", exePath: diffToolPath, binaryExtensions: new[] { "knownBin" }); var binPath = AllFiles.Files["jpg"]; var newPath = Path.ChangeExtension(binPath.Path, "knownBin"); File.Copy(binPath.Path, newPath, true); AllFiles.UseFile(Category.Image, newPath); SharedVerifySettings.RegisterFileConverter <TypeToSplit>( "txt", (split, settings) => new ConversionResult( split.Info, new List <Stream> { new MemoryStream(FileHelpers.Utf8NoBOM.GetBytes(split.Property1)), new MemoryStream(FileHelpers.Utf8NoBOM.GetBytes(split.Property2)) })); DiffRunner.MaxInstancesToLaunch(int.MaxValue); }
public DatReader GetReaderForFile(uint fileId) { if (AllFiles.TryGetValue(fileId, out var file)) { DatReader dr; if (stream != null) { lock (streamMutex) dr = new DatReader(stream, file.FileOffset, file.FileSize, Header.BlockSize); } else { dr = new DatReader(FilePath, file.FileOffset, file.FileSize, Header.BlockSize); } return(dr); } if ((fileId & 0xFFFF) == 0xFFFE) // These are LandBlockInfo objects. Not every landblock has extra info (buildings, etc..) { log.DebugFormat("Unable to find object_id {0:X8} in {1}", fileId, Enum.GetName(typeof(DatDatabaseType), Header.DataSet)); } else { log.InfoFormat("Unable to find object_id {0:X8} in {1}", fileId, Enum.GetName(typeof(DatDatabaseType), Header.DataSet)); } return(null); }
public override Task GetResults(ISearchResultCallback searchResultCallback, SearchPopupSearchPattern pattern, CancellationToken token) { return(Task.Run(delegate { var files = AllFiles.ToList(); var matcher = StringMatcher.GetMatcher(pattern.Pattern, false); var savedMatches = new Dictionary <string, MatchResult> (); foreach (ProjectFile file in files) { if (token.IsCancellationRequested) { break; } int rank; string matchString = System.IO.Path.GetFileName(file.FilePath); if (MatchName(savedMatches, matcher, matchString, out rank)) { searchResultCallback.ReportResult(new FileSearchResult(pattern.Pattern, matchString, rank, file, true)); } matchString = FileSearchResult.GetRelProjectPath(file); if (MatchName(savedMatches, matcher, matchString, out rank)) { searchResultCallback.ReportResult(new FileSearchResult(pattern.Pattern, matchString, rank, file, true)); } } }, token)); }
/// <summary> /// Initializes a new instance of the <see cref="FileExpressionList"/> class. /// </summary> /// <param name="rawFileListString">The unprocessed list of file expressions.</param> /// <param name="project">The project where the expression list exists.</param> /// <param name="task">The task where the expression list exists.</param> public FileExpressionList(string rawFileListString, ProjectInstance project, ProjectTaskInstance task) { IList <string> expressions = rawFileListString.SplitStringList(); var seenFiles = new HashSet <string>(PathComparer.Instance); foreach (string expression in expressions) { FileExpressionBase parsedExpression = FileExpressionFactory.ParseExpression(expression, project, task); Expressions.Add(parsedExpression); foreach (string file in parsedExpression.EvaluatedFiles) { if (string.IsNullOrWhiteSpace(file)) { continue; } if (seenFiles.Add(file)) { DedupedFiles.Add(file); } AllFiles.Add(file); } } }
/// <summary> /// Dictionary<files,datetime last write> всех файлов в Projdir /// </summary> public filesdates AllFiles() { filesdates res = new filesdates(); if (!IsOnline) { return(res); } string[] AllFiles; if (_allfiles == null) { // tmr.Start("===GetFilesInDir = " + Dir, 22); // CONSTS.AddToTempLine("Получение файлов из " + Dir); AllFiles = GetfilesIndir(Dir); //запуск поиска всех файлов директории проекта // tmr.Stop(22); } else { return(_allfiles); } var n = AllFiles.Count(); //tmr.Stop(22); // tmr.Start("Перевод в структуру filesdates ",23); foreach (var file in AllFiles) { res.Add(file, File.GetLastWriteTime(file)); } // tmr.Stop(23); _allfiles = res; return(res); }
public void CreateFile() { var pathOfFileToCreate = "file.jpg"; File.Delete(pathOfFileToCreate); #region CreateFile AllFiles.CreateFile(pathOfFileToCreate); #endregion Assert.True(File.Exists(pathOfFileToCreate)); File.Delete(pathOfFileToCreate); AllFiles.CreateFile("foo.txt", true); Assert.True(File.Exists("foo.txt")); File.Delete("foo.txt"); Assert.True(AllFiles.TryCreateFile(pathOfFileToCreate)); Assert.True(File.Exists(pathOfFileToCreate)); File.Delete(pathOfFileToCreate); Assert.False(AllFiles.TryCreateFile("foo.txt")); Assert.False(File.Exists("foo.txt")); File.Delete("foo.txt"); Assert.True(AllFiles.TryCreateFile("foo.txt", true)); Assert.True(File.Exists("foo.txt")); File.Delete("foo.txt"); }
public async Task <IndexRoot> Integrate(ICollection <VirtualFile> files) { Utils.Log($"Integrating {files.Count} files"); var allFiles = AllFiles.Concat(files) .OrderByDescending(f => f.LastModified) .GroupBy(f => f.FullPath).Select(g => g.Last()) .ToList(); var byFullPath = Task.Run(() => allFiles.SelectMany(f => f.ThisAndAllChildren) .ToDictionary(f => f.FullPath)); var byHash = Task.Run(() => allFiles.SelectMany(f => f.ThisAndAllChildren) .Where(f => f.Hash != Hash.Empty) .ToLookup(f => f.Hash)); var byName = Task.Run(() => allFiles.SelectMany(f => f.ThisAndAllChildren) .ToLookup(f => f.Name)); var byRootPath = Task.Run(() => allFiles.ToDictionary(f => f.AbsoluteName)); var result = new IndexRoot(allFiles, await byFullPath, await byHash, await byRootPath, await byName); Utils.Log($"Done integrating"); return(result); }
//public bool AreAllFilesRecommended() //{ // var extensions = new List<string>(); // string[] ignore = { ".map" }; // foreach (string file in Files) // { // string ext = Path.GetExtension(file).ToLowerInvariant(); // if (!ignore.Contains(ext) && !extensions.Contains(ext)) // extensions.Add(ext); // if (extensions.Count >= 2) // return true; // } // return false; //} internal async Task DownloadFilesAsync(string downloadDir) { if (Directory.Exists(downloadDir)) { return; } var list = DownloadFiles(downloadDir, Files); OnDownloading(downloadDir); await Task.WhenAll(list); var remaining = AllFiles.Where(f => !Files.Contains(f)); if (remaining.Any()) { // Fire and forget to return call immediately. Download the rest of the files // TODO: Is there a more elegant way than using the threadpool like this? System.Threading.ThreadPool.QueueUserWorkItem(async(o) => { OnDownloadingRemainingFiles(downloadDir); await Task.WhenAll(DownloadFiles(downloadDir, remaining)); }); } }
/// <summary> /// Initializes a new instance of the <see cref="FileExpressionList"/> class. /// </summary> /// <param name="rawFileListString">The unprocessed list of file expressions.</param> /// <param name="project">The project where the expression list exists.</param> /// <param name="task">The task where the expression list exists.</param> public FileExpressionList(string rawFileListString, ProjectInstance project, ProjectTaskInstance task) { List <string> expressions = rawFileListString.SplitStringList(); NumExpressions = expressions.Count; var seenFiles = new HashSet <string>(PathComparer.Instance); foreach (string expression in expressions) { List <string> evaluatedFiles = FileExpression.EvaluateExpression(expression, project, task, out bool isBatched); if (isBatched) { NumBatchExpressions++; } foreach (string file in evaluatedFiles) { if (string.IsNullOrWhiteSpace(file)) { continue; } if (seenFiles.Add(file)) { DedupedFiles.Add(file); } AllFiles.Add(file); } } }
public async Task <IndexRoot> Integrate(ICollection <VirtualFile> files) { Utils.Log($"Integrating {files.Count} files"); var allFiles = AllFiles.Concat(files).GroupBy(f => f.Name).Select(g => g.Last()).ToImmutableList(); var byFullPath = Task.Run(() => allFiles.SelectMany(f => f.ThisAndAllChildren) .ToImmutableDictionary(f => f.FullPath)); var byHash = Task.Run(() => allFiles.SelectMany(f => f.ThisAndAllChildren) .Where(f => f.Hash != null) .ToGroupedImmutableDictionary(f => f.Hash)); var byName = Task.Run(() => allFiles.SelectMany(f => f.ThisAndAllChildren) .ToGroupedImmutableDictionary(f => f.Name)); var byRootPath = Task.Run(() => allFiles.ToImmutableDictionary(f => f.Name)); var result = new IndexRoot(allFiles, await byFullPath, await byHash, await byRootPath, await byName); Utils.Log($"Done integrating"); return(result); }
public override void Hotload(List <string> changedFiles) { // TODO smarter hotloading. Handle removed files. var loadedFileNames = new HashSet <string>(AllFiles.Keys); foreach (string file in FindConfigsInBaseDir()) { string fileName = GetFileNameFromPath(file); loadedFileNames.Remove(fileName); if (!AllFiles.TryGetValue(fileName, out var fileInfo)) { // New file, add it. var newFileInfo = ReadFile(file); AllFiles.Add(newFileInfo.Name, newFileInfo); changedFiles.Add(newFileInfo.Name); continue; } var fileSize = new FileInfo(file).Length; var modified = File.GetLastWriteTimeUtc(file); // Timestamp or size need to differ before we bother generating a checksum of the file. // Timestamps are considered different if there's at least 1 second between them. if (fileSize == fileInfo.Size && Math.Abs((modified - fileInfo.Modified).TotalSeconds) < 1f) { continue; } using (var fileStream = File.OpenRead(file)) { int checksum = Internal.ChecksumUtils.Checksum(fileStream); fileStream.Seek(0, SeekOrigin.Begin); // Update the modified timestamp and file size even if the checksum is the same. // Because we didn't early out a few lines above, we know that at least one of these values // is stale. fileInfo.Modified = modified; fileInfo.Size = fileSize; if (checksum == fileInfo.Checksum) { // The files are identical. continue; } // File has changed. Hotload it. fileInfo.Checksum = checksum; fileInfo.Modified = modified; fileInfo.Parsed = Configs.LoadDocFromStream(fileStream, file); changedFiles.Add(fileName); } } foreach (string deletedFile in loadedFileNames) { AllFiles.Remove(deletedFile); changedFiles.Add(deletedFile); } }
public void Aliases() { var path = AllFiles.GetPathFor("jpeg"); Assert.True(AllFiles.IsEmptyFile(path)); Assert.Contains("jpeg", AllFiles.ImageExtensions); }
private void GenerateFiles() { AllFiles.Clear(); foreach (var file in _fileRenamerModel.Files) { AllFiles.Add(new FileViewModel(file)); } }
public override void Preload() { foreach (string file in FindConfigsInBaseDir()) { var fileInfo = ReadFile(file); AllFiles.Add(fileInfo.Name, fileInfo); } }
public void UseFile() { var pathToFile = SourceFile; #region UseFile AllFiles.UseFile(Category.Document, pathToFile); Assert.Contains(pathToFile, AllFiles.DocumentPaths); #endregion }
public override IEnumerable <string> MatchingFiles() { var allModifiedFiles = _modifiedFiles .Union(_modifiedDirectories .SelectMany(d => Directory.EnumerateFiles(d, "*.*", SearchOption.AllDirectories))) .ToHashSet(); return(AllFiles.Where(f => allModifiedFiles.Any(m => m.ToLower().EndsWith(f.ToLower())))); }
public void Filter() { // Filter all files in the directory for those satisfying the given filters Files.ReplaceAll(AllFiles.Where(x => (FilterExtension == "" || x.OldExtension == FilterExtension) && (FilterFullName ? x.OldFullName : x.OldName).RegexContains(FilterRegex ? FilterPattern : Regex.Escape(FilterPattern)))); Preview(); }
public void OpenDirectory(string directory) { WorkingDirectory = directory.Replace('\\', '/'); AllFiles.ReplaceAll(Directory.GetFiles(WorkingDirectory).Select(x => new FileModel(x.Replace('\\', '/')))); new Sort() { Mode = SortMode.Natural }.ApplyTo(AllFiles); Filter(); }
private FileResult DownloadFile(AllFiles userFiles) { //AllFiles userFile = RepositoryAllFiles.AllFiles.First(uf => uf.FileId == userFiles.FileId); string path = Server.MapPath("~/AllUsersFiles/") + RepositoryGroupFiles.GetFileGuidById(userFiles.FileId) + @"/" + userFiles.FileId + @"/" + userFiles.FileName; byte[] fileBytes = System.IO.File.ReadAllBytes(path); return(File(fileBytes, userFiles.FileExtension, userFiles.FileName)); }
public void GetPathFor() { #region GetPathFor var path = AllFiles.GetPathFor("jpg"); #endregion var path2 = AllFiles.GetPathFor(".jpg"); Assert.NotNull(path); Assert.NotNull(path2); Assert.True(File.Exists(path)); Assert.True(File.Exists(path2)); }
public DatReader GetReaderForFile(uint fileId) { if (AllFiles.TryGetValue(fileId, out var file)) { DatReader dr = new DatReader(FilePath, file.FileOffset, file.FileSize, Header.BlockSize); return(dr); } log.InfoFormat("Unable to find object_id {0} in {1}", fileId, Enum.GetName(typeof(DatDatabaseType), Header.DataSet)); return(null); }
private void cbShowSelectedElements_CheckedChanged(object sender, EventArgs e) { if ((sender as CheckBox).Checked) { numberedFileInfoBindingSource.DataSource = AllFiles.Where(f => f.ToDelete); } else { numberedFileInfoBindingSource.DataSource = AllFiles; } }
protected EvaluationResult Evaluate(string[] predictedDefectFiles) { var allFiles = AllFiles.Select(x => x.Path).ToArray(); return(new EvaluationResult( DefectFiles, allFiles.Except(DefectFiles).ToArray(), predictedDefectFiles, allFiles.Except(predictedDefectFiles).ToArray() )); }
public void Unknown_extension() { Assert.Throws <Exception>(() => AllFiles.GetPathFor("txt")); Assert.False(AllFiles.TryGetPathFor("txt", out var result)); Assert.Null(result); Assert.False(AllFiles.TryGetPathFor(".txt", out result)); Assert.Null(result); Assert.False(AllFiles.TryCreateFile("foo.txt")); Assert.Null(result); Assert.Throws <Exception>(() => AllFiles.GetPathFor(".txt")); Assert.Throws <Exception>(() => AllFiles.CreateFile("foo.txt")); }
private List <string> FilterList(string extension) { return(AllFiles.Where(file => file.Contains(extension)).ToList()); //var newList = new List<string>(); //foreach (string file in AllFiles) { // if (file.Contains(extension)) { // newList.Add(file); // } //} //return newList; }
public void CreateRoot(File newFile = null) { if (newFile == null) { AllFiles.Add(File.GetRoot(this)); } else { newFile.Parent = null; AllFiles.Add(newFile); } }
public DatReader GetReaderForFile(uint object_id) { if (AllFiles.ContainsKey(object_id)) { DatReader dr = new DatReader(FilePath, AllFiles[object_id].FileOffset, AllFiles[object_id].FileSize, SectorSize); return(dr); } else { log.InfoFormat("Unable to find object_id {0} in {1}", object_id.ToString(), Enum.GetName(typeof(DatDatabaseType), DatType)); return(null); } }
public void Update(AllFiles allFiles) { Update(allFiles, RealPath); }
protected void Update(AllFiles allFiles, string realPathDir) { string readDir = Path.Combine(Directory.GetCurrentDirectory(), realPathDir); string realPath = null; this.Contents.Clear(); foreach (string file in Directory.GetFiles(readDir)) { realPath = Path.Combine(realPathDir, Path.GetFileName(file)); if (!allFiles.Any(f => Path.Equals(f.RealPath, realPath))) this.Add(new OtherFile() { Name = Path.GetFileName(file), RealPath = realPath, }); } foreach (string dir in Directory.GetDirectories(readDir)) { realPath = Path.Combine(realPathDir, Path.GetFileName(dir)); OtherFilesFolder child = new OtherFilesFolder() { Name = Path.GetFileName(dir), RealPath = realPath, }; child.Update(allFiles, Path.Combine(realPathDir, child.Name)); this.Add(child); } }
private void UpdateOtherFiles(OtherFilesFolder folder, AllFiles allFiles, string savePathDir) { string pathOffset = Path.GetDirectoryName(SavePath); string realPath = null; foreach (string file in Directory.GetFiles(savePathDir)) { realPath = file.Substring(pathOffset.Length + (pathOffset.EndsWith("\\")? 0 : 1)); if (!allFiles.Any(f => Path.Equals(f.RealPath, realPath))) folder.Add(new OtherFile() { Name = Path.GetFileName(file), RealPath = realPath }); } foreach (string dir in Directory.GetDirectories(savePathDir)) { OtherFilesFolder child = new OtherFilesFolder() { Name = Path.GetFileName(dir), }; UpdateOtherFiles(child, allFiles, dir+"\\"); folder.Add(child); } }
private void UpdateOtherFiles() { OtherFilesFolder off = (OtherFilesFolder)BaseFolder.Contents.FirstOrDefault(f => f is OtherFilesFolder); AllFiles allFiles = new AllFiles(BaseFolder); if(off == null){ off = new OtherFilesFolder(); BaseFolder.Add(off); } else{ off.Contents.Clear(); } off.Update(allFiles); }
private void ExecuteRefresh(object sender, ExecutedRoutedEventArgs args) { AllFiles allFiles = new AllFiles(Project.BaseFolder); (args.Parameter as OtherFilesFolder).Update(allFiles); }