public static List <String> loadSourceFileIntoList(String pathToSourceCodeFile, bool useFileCacheIfPossible) { if (useFileCacheIfPossible && PublicDI.dFilesLines.ContainsKey(pathToSourceCodeFile)) { return(PublicDI.dFilesLines[pathToSourceCodeFile]); } // in case the file is a reference, try to map it string mappedSourceCodeFile = SourceCodeMappingsUtils.mapFile(pathToSourceCodeFile); var lsSourceCode = new List <string>(); string sFileContents = getFileContents(mappedSourceCodeFile); if (sFileContents != "") { sFileContents = sFileContents.Replace("\r\n", "\n").Replace("\n", Environment.NewLine); // fix the files only use \n for line breaks lsSourceCode.AddRange(sFileContents.Split(new[] { Environment.NewLine }, StringSplitOptions.None)); if (false == PublicDI.dFilesLines.ContainsKey(pathToSourceCodeFile)) { PublicDI.dFilesLines.Add(pathToSourceCodeFile, lsSourceCode); } else { PublicDI.dFilesLines[pathToSourceCodeFile] = lsSourceCode; } } return(lsSourceCode); }
public static long getFileSize(string fileToProcess) { string mappedSourceCodeFile = SourceCodeMappingsUtils.mapFile(fileToProcess); if (File.Exists(mappedSourceCodeFile)) { var fileInfo = new FileInfo(mappedSourceCodeFile); return(fileInfo.Length); } return(-1); }
public static long getFilesSize(List <string> filesToProcess) { long filesSize = 0; foreach (var file in filesToProcess) { string mappedSourceCodeFile = SourceCodeMappingsUtils.mapFile(file); if (File.Exists(mappedSourceCodeFile)) { var fileInfo = new FileInfo(mappedSourceCodeFile); filesSize += fileInfo.Length; } } return((filesSize == 0) ? -1 : filesSize); }