本文整理汇总了C#中FilePath.ToEnvironmentalPath方法的典型用法代码示例。如果您正苦于以下问题:C# FilePath.ToEnvironmentalPath方法的具体用法?C# FilePath.ToEnvironmentalPath怎么用?C# FilePath.ToEnvironmentalPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilePath
的用法示例。
在下文中一共展示了FilePath.ToEnvironmentalPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFirstMatch
public FilePath GetFirstMatch(FilePath root, string pattern)
{
var first = Directory.EnumerateFiles(root.ToEnvironmentalPath(), pattern, SearchOption.TopDirectoryOnly)
.FirstOrDefault();
if (string.IsNullOrEmpty(first)) return null;
return (FilePath)first;
}
示例2: DirectoryExists
public bool DirectoryExists(FilePath p)
{
try
{
return Directory.Exists(p.ToEnvironmentalPath());
}
catch
{
return false;
}
}
示例3: DeletePath
public void DeletePath(FilePath path)
{
var epath = path.ToEnvironmentalPath();
var gitPath = path.Navigate((FilePath)".git").ToEnvironmentalPath();
if (Directory.Exists(gitPath)) Directory.Delete(gitPath, true);
if (Directory.Exists(epath))
Directory.Delete(epath, true);
else
File.Delete(epath);
}
示例4: CopyBuildResultsTo
public void CopyBuildResultsTo(FilePath dest)
{
// For every file in dest, if we have a newer copy then overwrite dest file.
// masters always override other available files
if (!Directory.Exists(dest.ToEnvironmentalPath())) return;
var files = Directory.GetFiles(dest.ToEnvironmentalPath(), _patterns.DependencyPattern, SearchOption.TopDirectoryOnly);
foreach (var target in files)
{
var name = Path.GetFileName(target);
if (name == null) continue;
var source = _masters.Of(name) ?? _available.Of(name);
if (source == null)
{
Log.Verbose("No source for => " + target);
continue;
}
Log.Verbose(source.FullName + " => " + target);
source.CopyTo(target, true);
}
}
示例5: SetByLatest
static void SetByLatest(FilePath srcPath, IDictionary<string, FileInfo> repo, string pattern)
{
var files = Directory.GetFiles(srcPath.ToEnvironmentalPath(), pattern, SearchOption.AllDirectories);
foreach (var file in files)
{
var name = Path.GetFileName(file);
if (name == null) continue;
var newInfo = new FileInfo(file);
if (!repo.ContainsKey(name))
{
repo.Add(name, newInfo);
continue;
}
var existing = repo[name];
if (newInfo.LastWriteTime > existing.LastWriteTime)
repo[name] = newInfo;
}
}
示例6: CopyDirectory
public void CopyDirectory(FilePath src, FilePath dst)
{
if (!DirectoryExists(src)) throw new Exception("Source was not a folder or doesn't exist");
if (IsFile(dst)) throw new Exception("Destination already exists as a file");
if (DirectoryExists(dst))
{
try
{
DeletePath(dst);
}
catch
{
throw new Exception("Tried to delete " + dst + " to replace it, but failed");
}
}
DirectoryCopy(src.ToEnvironmentalPath(), dst.ToEnvironmentalPath(), true);
}
示例7: Should_throw_if_file_doesnt_have_an_extension
public void Should_throw_if_file_doesnt_have_an_extension(string inputPath)
{
var filePath = new FilePath(inputPath);
var ex = Assert.Throws<InvalidOperationException>(()=>filePath.Extension());
Assert.That(ex.Message, Is.EqualTo(string.Format("{0} does not have an extension", filePath.ToEnvironmentalPath())));
}
示例8: UpdateAvailableDependencies
public void UpdateAvailableDependencies(FilePath srcPath)
{
if (!Directory.Exists(srcPath.ToEnvironmentalPath())) return;
// for every pattern file under srcPath, add to list if it's the newest
SetByLatest(srcPath, _available, _patterns.DependencyPattern);
}
示例9: ReadModules
void ReadModules(FilePath filePath)
{
Log.Verbose("Reading " + filePath.ToEnvironmentalPath());
var lines = _files.Lines(filePath);
var c = lines.Length;
Repos = new string[c]; // src id => src repo
Paths = new string[c]; // src id => file path
Deps = new List<int>[c]; // src id => dst
for (int i = 0; i < c; i++)
{
Log.Verbose(lines[i]);
var bits = lines[i].Split('=').Select(s => s.Trim()).ToArray();
Repos[i] = bits[1];
Paths[i] = bits[0];
Deps[i] = new List<int>();
}
}
示例10: Lines
public string[] Lines(FilePath path)
{
return
File.ReadAllLines(path.ToEnvironmentalPath())
.Where(l => !l.StartsWith("#") && !string.IsNullOrWhiteSpace(l)).ToArray();
}
示例11: IsFile
public bool IsFile(FilePath target)
{
try
{
return File.Exists(target.ToEnvironmentalPath());
}
catch
{
return false;
}
}
示例12: CloneMissingRepos
void CloneMissingRepos()
{
for (int i = 0; i < Modules.Paths.Length; i++)
{
var path = new FilePath(Modules.Paths[i]);
var expected = _rootPath.Navigate(path);
if (_files.Exists(expected)) continue;
Log.Info(path.ToEnvironmentalPath() + " is missing. Cloning...");
_git.Clone(_rootPath, expected, Modules.Repos[i]);
}
}
示例13: Exists
public bool Exists(FilePath filePath)
{
return File.Exists(filePath.ToEnvironmentalPath())
|| Directory.Exists(filePath.ToEnvironmentalPath());
}
示例14: RebuildByFluentMigration
private void RebuildByFluentMigration(FilePath projPath, FilePath psScript)
{
var createDatabase = projPath.Append(new FilePath("DatabaseScripts")).Append(new FilePath("CreateDatabase.sql"));
Log.Status("Creating database from " + createDatabase.ToEnvironmentalPath());
_builder.RunSqlScripts(projPath, createDatabase);
Log.Status("Running RunMigrationsLocally.ps1");
projPath.Call("powershell " + psScript.ToEnvironmentalPath(), "");
}
示例15: RunSqlScripts
public int RunSqlScripts(FilePath root, FilePath script)
{
Log.Status(" " + script.LastElement());
return root.Call("sqlcmd.exe", "-f 65001 -i \"" + script.ToEnvironmentalPath() + "\" -S . -E");
}