本文整理汇总了C#中Sharpen.FilePath.ListFiles方法的典型用法代码示例。如果您正苦于以下问题:C# FilePath.ListFiles方法的具体用法?C# FilePath.ListFiles怎么用?C# FilePath.ListFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sharpen.FilePath
的用法示例。
在下文中一共展示了FilePath.ListFiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test001_Initalize
public virtual void Test001_Initalize()
{
FilePath gitdir = new FilePath(trash, Constants.DOT_GIT);
FilePath hooks = new FilePath(gitdir, "hooks");
FilePath objects = new FilePath(gitdir, "objects");
FilePath objects_pack = new FilePath(objects, "pack");
FilePath objects_info = new FilePath(objects, "info");
FilePath refs = new FilePath(gitdir, "refs");
FilePath refs_heads = new FilePath(refs, "heads");
FilePath refs_tags = new FilePath(refs, "tags");
FilePath HEAD = new FilePath(gitdir, "HEAD");
NUnit.Framework.Assert.IsTrue(trash.IsDirectory(), "Exists " + trash);
NUnit.Framework.Assert.IsTrue(hooks.IsDirectory(), "Exists " + hooks);
NUnit.Framework.Assert.IsTrue(objects.IsDirectory(), "Exists " + objects);
NUnit.Framework.Assert.IsTrue(objects_pack.IsDirectory(), "Exists " + objects_pack
);
NUnit.Framework.Assert.IsTrue(objects_info.IsDirectory(), "Exists " + objects_info
);
NUnit.Framework.Assert.AreEqual(2L, objects.ListFiles().Length);
NUnit.Framework.Assert.IsTrue(refs.IsDirectory(), "Exists " + refs);
NUnit.Framework.Assert.IsTrue(refs_heads.IsDirectory(), "Exists " + refs_heads);
NUnit.Framework.Assert.IsTrue(refs_tags.IsDirectory(), "Exists " + refs_tags);
NUnit.Framework.Assert.IsTrue(HEAD.IsFile(), "Exists " + HEAD);
NUnit.Framework.Assert.AreEqual(23, HEAD.Length());
}
示例2: DeleteRecursive
public static bool DeleteRecursive(FilePath fileOrDirectory)
{
if (fileOrDirectory.IsDirectory())
{
foreach (FilePath child in fileOrDirectory.ListFiles())
{
DeleteRecursive(child);
}
}
bool result = fileOrDirectory.Delete() || !fileOrDirectory.Exists();
return result;
}
示例3: AddCategories
private static void AddCategories(TestSuite suite, FilePath suiteDir, string prefix, string[] excludes, int optimizationLevel)
{
FilePath[] subdirs = suiteDir.ListFiles(ShellTest.DIRECTORY_FILTER);
Arrays.Sort(subdirs);
for (int i = 0; i < subdirs.Length; i++)
{
FilePath subdir = subdirs[i];
string name = subdir.GetName();
TestSuite testCategory = new TestSuite(name);
AddTests(testCategory, subdir, prefix + name + "/", excludes, optimizationLevel);
suite.AddTest(testCategory);
}
}
示例4: AddTests
private static void AddTests(TestSuite suite, FilePath suiteDir, string prefix, string[] excludes, int optimizationLevel)
{
FilePath[] jsFiles = suiteDir.ListFiles(ShellTest.TEST_FILTER);
Arrays.Sort(jsFiles);
for (int i = 0; i < jsFiles.Length; i++)
{
FilePath jsFile = jsFiles[i];
string name = jsFile.GetName();
if (!TestUtils.Matches(excludes, prefix + name))
{
suite.AddTest(new StandardTests.JsTestCase(jsFile, optimizationLevel));
}
}
}
示例5: RecursiveListFilesHelper
public static void RecursiveListFilesHelper(FilePath dir, FileFilter filter, IList<FilePath> fileList)
{
foreach (FilePath f in dir.ListFiles())
{
if (f.IsDirectory())
{
RecursiveListFilesHelper(f, filter, fileList);
}
else
{
if (filter.Accept(f))
{
fileList.Add(f);
}
}
}
}
示例6: AddSuites
private static void AddSuites(TestSuite topLevel, FilePath testDir, string[] excludes, int optimizationLevel)
{
FilePath[] subdirs = testDir.ListFiles(ShellTest.DIRECTORY_FILTER);
Arrays.Sort(subdirs);
for (int i = 0; i < subdirs.Length; i++)
{
FilePath subdir = subdirs[i];
string name = subdir.GetName();
if (TestUtils.Matches(excludes, name))
{
continue;
}
TestSuite testSuite = new TestSuite(name);
AddCategories(testSuite, subdir, name + "/", excludes, optimizationLevel);
topLevel.AddTest(testSuite);
}
}
示例7: AddTests
private static void AddTests(TestSuite suite, FilePath testDir, string name)
{
FilePath programFile = new FilePath(testDir, "program.js");
if (programFile.IsFile())
{
suite.AddTest(CreateTest(testDir, name));
}
else
{
FilePath[] files = testDir.ListFiles();
foreach (FilePath file in files)
{
if (file.IsDirectory())
{
AddTests(suite, file, name + "/" + file.GetName());
}
}
}
}
示例8: UpgradeOldDatabaseFiles
private void UpgradeOldDatabaseFiles(FilePath directory)
{
FilePath[] files = directory.ListFiles(new _FilenameFilter_330());
foreach (FilePath file in files)
{
string oldFilename = file.GetName();
string newFilename = FilenameWithNewExtension(oldFilename, DatabaseSuffixOld, DatabaseSuffix
);
FilePath newFile = new FilePath(directory, newFilename);
if (newFile.Exists())
{
Log.W(Database.Tag, "Cannot rename %s to %s, %s already exists", oldFilename, newFilename
, newFilename);
continue;
}
bool ok = file.RenameTo(newFile);
if (!ok)
{
string msg = string.Format("Unable to rename %s to %s", oldFilename, newFilename);
throw new InvalidOperationException(msg);
}
}
}
示例9: Delete
/// <summary>Delete file or folder</summary>
/// <param name="f">
/// <code>File</code>
/// to be deleted
/// </param>
/// <param name="options">
/// deletion options,
/// <code>RECURSIVE</code>
/// for recursive deletion of
/// a subtree,
/// <code>RETRY</code>
/// to retry when deletion failed.
/// Retrying may help if the underlying file system doesn't allow
/// deletion of files being read by another thread.
/// </param>
/// <exception cref="System.IO.IOException">
/// if deletion of
/// <code>f</code>
/// fails. This may occur if
/// <code>f</code>
/// didn't exist when the method was called. This can therefore
/// cause IOExceptions during race conditions when multiple
/// concurrent threads all try to delete the same file.
/// </exception>
public static void Delete(FilePath f, int options)
{
if ((options & SKIP_MISSING) != 0 && !f.Exists())
{
return;
}
if ((options & RECURSIVE) != 0 && f.IsDirectory())
{
FilePath[] items = f.ListFiles();
if (items != null)
{
foreach (FilePath c in items)
{
Delete(c, options);
}
}
}
if (!f.Delete())
{
if ((options & RETRY) != 0 && f.Exists())
{
for (int i = 1; i < 10; i++)
{
try
{
Sharpen.Thread.Sleep(100);
}
catch (Exception)
{
}
// ignore
if (f.Delete())
{
return;
}
}
}
throw new IOException(MessageFormat.Format(JGitText.Get().deleteFileFailed, f.GetAbsolutePath
()));
}
}
示例10: TestUpgradeOldDatabaseFiles
/// <exception cref="System.Exception"></exception>
public virtual void TestUpgradeOldDatabaseFiles()
{
string directoryName = "test-directory-" + Runtime.CurrentTimeMillis();
string normalFilesDir = GetRootDirectory().GetAbsolutePath();
string fakeFilesDir = string.Format("%s/%s", normalFilesDir, directoryName);
FilePath directory = new FilePath(fakeFilesDir);
if (!directory.Exists())
{
bool result = directory.Mkdir();
if (!result)
{
throw new IOException("Unable to create directory " + directory);
}
}
FilePath oldTouchDbFile = new FilePath(directory, string.Format("old%s", Manager.
DatabaseSuffixOld));
oldTouchDbFile.CreateNewFile();
FilePath newCbLiteFile = new FilePath(directory, string.Format("new%s", Manager.DatabaseSuffix
));
newCbLiteFile.CreateNewFile();
FilePath migratedOldFile = new FilePath(directory, string.Format("old%s", Manager
.DatabaseSuffix));
migratedOldFile.CreateNewFile();
base.StopCBLite();
manager = new Manager(new FilePath(GetRootDirectory(), directoryName), Manager.DefaultOptions
);
NUnit.Framework.Assert.IsTrue(migratedOldFile.Exists());
//cannot rename old.touchdb in old.cblite, old.cblite already exists
NUnit.Framework.Assert.IsTrue(oldTouchDbFile.Exists());
NUnit.Framework.Assert.IsTrue(newCbLiteFile.Exists());
FilePath dir = new FilePath(GetRootDirectory(), directoryName);
NUnit.Framework.Assert.AreEqual(3, dir.ListFiles().Length);
base.StopCBLite();
migratedOldFile.Delete();
manager = new Manager(new FilePath(GetRootDirectory(), directoryName), Manager.DefaultOptions
);
//rename old.touchdb in old.cblite, previous old.cblite already doesn't exist
NUnit.Framework.Assert.IsTrue(migratedOldFile.Exists());
NUnit.Framework.Assert.IsTrue(oldTouchDbFile.Exists() == false);
NUnit.Framework.Assert.IsTrue(newCbLiteFile.Exists());
dir = new FilePath(GetRootDirectory(), directoryName);
NUnit.Framework.Assert.AreEqual(2, dir.ListFiles().Length);
}
示例11: ListFiles
private void ListFiles(FilePath dir, AList<string> list)
{
foreach (FilePath f in dir.ListFiles())
{
if (f.IsDirectory())
{
ListFiles(f, list);
}
else
{
list.AddItem(Repository.StripWorkDir(root, f));
}
}
}
示例12: AddFiles
private void AddFiles(IList<JsDriver.Tests.Script> rv, string prefix, FilePath directory)
{
FilePath[] files = directory.ListFiles();
if (files == null)
{
throw new Exception("files null for " + directory);
}
for (int i = 0; i < files.Length; i++)
{
string path = prefix + files[i].GetName();
if (ShellTest.DIRECTORY_FILTER.Accept(files[i]))
{
AddFiles(rv, path + "/", files[i]);
}
else
{
bool isTopLevel = prefix.Length == 0;
if (ShellTest.TEST_FILTER.Accept(files[i]) && Matches(path) && !Excluded(path) && !isTopLevel)
{
rv.Add(new JsDriver.Tests.Script(path, files[i]));
}
}
}
}
示例13: DeleteBlobsExceptWithKeys
public int DeleteBlobsExceptWithKeys(IList<BlobKey> keysToKeep)
{
int numDeleted = 0;
FilePath file = new FilePath(path);
FilePath[] contents = file.ListFiles();
foreach (FilePath attachment in contents)
{
BlobKey attachmentKey = new BlobKey();
GetKeyForFilename(attachmentKey, attachment.GetPath());
if (!keysToKeep.Contains(attachmentKey))
{
bool result = attachment.Delete();
if (result)
{
++numDeleted;
}
else
{
Log.E(Database.Tag, "Error deleting attachmetn");
}
}
}
return numDeleted;
}
示例14: TotalDataSize
public long TotalDataSize()
{
long total = 0;
FilePath file = new FilePath(path);
FilePath[] contents = file.ListFiles();
foreach (FilePath attachment in contents)
{
total += attachment.Length();
}
return total;
}
示例15: Count
public int Count()
{
FilePath file = new FilePath(path);
FilePath[] contents = file.ListFiles();
return contents.Length;
}