当前位置: 首页>>代码示例>>C#>>正文


C# FilePath.Mkdir方法代码示例

本文整理汇总了C#中Sharpen.FilePath.Mkdir方法的典型用法代码示例。如果您正苦于以下问题:C# FilePath.Mkdir方法的具体用法?C# FilePath.Mkdir怎么用?C# FilePath.Mkdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sharpen.FilePath的用法示例。


在下文中一共展示了FilePath.Mkdir方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestSameDiff

		public virtual void TestSameDiff()
		{
			Write(new FilePath(db.Directory.GetParent(), "test.txt"), "test");
			FilePath folder = new FilePath(db.Directory.GetParent(), "folder");
			folder.Mkdir();
			Write(new FilePath(folder, "folder.txt"), "\n\n\n\nfolder");
			Git git = new Git(db);
			git.Add().AddFilepattern(".").Call();
			git.Commit().SetMessage("Initial commit").Call();
			Write(new FilePath(folder, "folder.txt"), "\n\n\n\nfolder change");
			PatchIdDiffFormatter df = new PatchIdDiffFormatter();
			df.SetRepository(db);
			df.SetPathFilter(PathFilter.Create("folder"));
			DirCacheIterator oldTree = new DirCacheIterator(db.ReadDirCache());
			FileTreeIterator newTree = new FileTreeIterator(db);
			df.Format(oldTree, newTree);
			df.Flush();
			NUnit.Framework.Assert.AreEqual("08fca5ac531383eb1da8bf6b6f7cf44411281407", df.GetCalulatedPatchId
				().Name);
			Write(new FilePath(folder, "folder.txt"), "a\n\n\n\nfolder");
			git.Add().AddFilepattern(".").Call();
			git.Commit().SetMessage("Initial commit").Call();
			Write(new FilePath(folder, "folder.txt"), "a\n\n\n\nfolder change");
			df = new PatchIdDiffFormatter();
			df.SetRepository(db);
			df.SetPathFilter(PathFilter.Create("folder"));
			oldTree = new DirCacheIterator(db.ReadDirCache());
			newTree = new FileTreeIterator(db);
			df.Format(oldTree, newTree);
			df.Flush();
			NUnit.Framework.Assert.AreEqual("08fca5ac531383eb1da8bf6b6f7cf44411281407", df.GetCalulatedPatchId
				().Name);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:33,代码来源:PatchIdDiffFormatterTest.cs

示例2: 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);
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:44,代码来源:ManagerTest.cs

示例3: TestDiff

		public virtual void TestDiff()
		{
			Write(new FilePath(db.Directory.GetParent(), "test.txt"), "test");
			FilePath folder = new FilePath(db.Directory.GetParent(), "folder");
			folder.Mkdir();
			Write(new FilePath(folder, "folder.txt"), "folder");
			Git git = new Git(db);
			git.Add().AddFilepattern(".").Call();
			git.Commit().SetMessage("Initial commit").Call();
			Write(new FilePath(folder, "folder.txt"), "folder change");
			PatchIdDiffFormatter df = new PatchIdDiffFormatter();
			df.SetRepository(db);
			df.SetPathFilter(PathFilter.Create("folder"));
			DirCacheIterator oldTree = new DirCacheIterator(db.ReadDirCache());
			FileTreeIterator newTree = new FileTreeIterator(db);
			df.Format(oldTree, newTree);
			df.Flush();
			NUnit.Framework.Assert.AreEqual("1ff64e0f9333e9b81967c3e8d7a81362b14d5441", df.GetCalulatedPatchId
				().Name);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:20,代码来源:PatchIdDiffFormatterTest.cs

示例4: TestDiffModified

		public virtual void TestDiffModified()
		{
			Write(new FilePath(db.WorkTree, "test.txt"), "test");
			FilePath folder = new FilePath(db.WorkTree, "folder");
			folder.Mkdir();
			Write(new FilePath(folder, "folder.txt"), "folder");
			Git git = new Git(db);
			git.Add().AddFilepattern(".").Call();
			git.Commit().SetMessage("Initial commit").Call();
			Write(new FilePath(folder, "folder.txt"), "folder change");
			OutputStream @out = new ByteArrayOutputStream();
			IList<DiffEntry> entries = git.Diff().SetOutputStream(@out).Call();
			NUnit.Framework.Assert.AreEqual(1, entries.Count);
			NUnit.Framework.Assert.AreEqual(DiffEntry.ChangeType.MODIFY, entries[0].GetChangeType
				());
			NUnit.Framework.Assert.AreEqual("folder/folder.txt", entries[0].GetOldPath());
			NUnit.Framework.Assert.AreEqual("folder/folder.txt", entries[0].GetNewPath());
			string actual = @out.ToString();
			string expected = "diff --git a/folder/folder.txt b/folder/folder.txt\n" + "index 0119635..95c4c65 100644\n"
				 + "--- a/folder/folder.txt\n" + "+++ b/folder/folder.txt\n" + "@@ -1 +1 @@\n" +
				 "-folder\n" + "\\ No newline at end of file\n" + "+folder change\n" + "\\ No newline at end of file\n";
			NUnit.Framework.Assert.AreEqual(expected.ToString(), actual);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:23,代码来源:DiffCommandTest.cs

示例5: SaveConfig

        /// <summary>
        /// 設定のファイル保存
        /// </summary>
        /// <param name="config">設定</param>
        public void SaveConfig(ConfigEntity config)
        {
            FilePath path = new FilePath(MainWindowModel.ApplicationDataPath);

            if (!path.Exists())
            {
                path.Mkdir();
            }
            string json = JsonConvert.SerializeObject(config, new Newtonsoft.Json.Converters.StringEnumConverter());

            StreamWriter sw = new StreamWriter(MainWindowModel.ConfigFile, false, Encoding.UTF8);

            sw.Write(json);

            sw.Close();
        }
开发者ID:SatoKazuto,项目名称:BluePlumGit,代码行数:20,代码来源:MainWindowModel.cs

示例6: CopyFolder

		/// <exception cref="System.IO.IOException"></exception>
		public static void CopyFolder(FilePath src, FilePath dest)
		{
			if (src.IsDirectory())
			{
				//if directory not exists, create it
				if (!dest.Exists())
				{
					dest.Mkdir();
				}
				//list all the directory contents
				string[] files = src.List();
				foreach (string file in files)
				{
					//construct the src and dest file structure
					FilePath srcFile = new FilePath(src, file);
					FilePath destFile = new FilePath(dest, file);
					//recursive copy
					CopyFolder(srcFile, destFile);
				}
			}
			else
			{
				CopyFile(src, dest);
			}
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:26,代码来源:FileDirUtils.cs

示例7: TestDiff

		public virtual void TestDiff()
		{
			Write(new FilePath(db.Directory.GetParent(), "test.txt"), "test");
			FilePath folder = new FilePath(db.Directory.GetParent(), "folder");
			folder.Mkdir();
			Write(new FilePath(folder, "folder.txt"), "folder");
			Git git = new Git(db);
			git.Add().AddFilepattern(".").Call();
			git.Commit().SetMessage("Initial commit").Call();
			Write(new FilePath(folder, "folder.txt"), "folder change");
			ByteArrayOutputStream os = new ByteArrayOutputStream();
			DiffFormatter df = new DiffFormatter(new BufferedOutputStream(os));
			df.SetRepository(db);
			df.SetPathFilter(PathFilter.Create("folder"));
			DirCacheIterator oldTree = new DirCacheIterator(db.ReadDirCache());
			FileTreeIterator newTree = new FileTreeIterator(db);
			df.Format(oldTree, newTree);
			df.Flush();
			string actual = os.ToString();
			string expected = "diff --git a/folder/folder.txt b/folder/folder.txt\n" + "index 0119635..95c4c65 100644\n"
				 + "--- a/folder/folder.txt\n" + "+++ b/folder/folder.txt\n" + "@@ -1 +1 @@\n" +
				 "-folder\n" + "\\ No newline at end of file\n" + "+folder change\n" + "\\ No newline at end of file\n";
			NUnit.Framework.Assert.AreEqual(expected.ToString(), actual);
		}
开发者ID:shoff,项目名称:ngit,代码行数:24,代码来源:DiffFormatterTest.cs

示例8: TestMkdirs

		public virtual void TestMkdirs()
		{
			FilePath root = new FilePath(trash, "test");
			NUnit.Framework.Assert.IsTrue(root.Mkdir());
			FilePath d = new FilePath(root, "test/test");
			FileUtils.Mkdirs(d);
			NUnit.Framework.Assert.IsTrue(d.Exists() && d.IsDirectory());
			try
			{
				FileUtils.Mkdirs(d);
				NUnit.Framework.Assert.Fail("creation of existing directory hierarchy must fail");
			}
			catch (IOException)
			{
			}
			// expected
			FileUtils.Mkdirs(d, true);
			NUnit.Framework.Assert.IsTrue(d.Exists() && d.IsDirectory());
			FileUtils.Delete(root, FileUtils.RECURSIVE);
			FilePath f = new FilePath(trash, "test");
			FileUtils.CreateNewFile(f);
			try
			{
				FileUtils.Mkdirs(d);
				NUnit.Framework.Assert.Fail("creation of directory having path conflicting with existing"
					 + " file must fail");
			}
			catch (IOException)
			{
			}
			// expected
			NUnit.Framework.Assert.IsTrue(f.Delete());
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:33,代码来源:FileUtilTest.cs

示例9: SubmoduleWithNoGitDirectory

		public virtual void SubmoduleWithNoGitDirectory()
		{
			Git git = new Git(db);
			WriteTrashFile("file.txt", "content");
			git.Add().AddFilepattern("file.txt").Call();
			RevCommit id = git.Commit().SetMessage("create file").Call();
			string path = "sub";
			DirCache cache = db.LockDirCache();
			DirCacheEditor editor = cache.Editor();
			editor.Add(new _PathEdit_311(id, path));
			editor.Commit();
			FilePath submoduleRoot = new FilePath(db.WorkTree, path);
			NUnit.Framework.Assert.IsTrue(submoduleRoot.Mkdir());
			NUnit.Framework.Assert.IsTrue(new FilePath(submoduleRoot, Constants.DOT_GIT).Mkdir
				());
			TreeWalk walk = new TreeWalk(db);
			DirCacheIterator indexIter = new DirCacheIterator(db.ReadDirCache());
			FileTreeIterator workTreeIter = new FileTreeIterator(db);
			walk.AddTree(indexIter);
			walk.AddTree(workTreeIter);
			walk.Filter = PathFilter.Create(path);
			NUnit.Framework.Assert.IsTrue(walk.Next());
			NUnit.Framework.Assert.IsFalse(indexIter.IdEqual(workTreeIter));
			NUnit.Framework.Assert.AreEqual(ObjectId.ZeroId, workTreeIter.EntryObjectId);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:25,代码来源:FileTreeIteratorTest.cs

示例10: Mkdir

 /// <summary>Creates the directory named by this abstract pathname.</summary>
 /// <remarks>Creates the directory named by this abstract pathname.</remarks>
 /// <param name="d">directory to be created</param>
 /// <param name="skipExisting">
 /// if
 /// <code>true</code>
 /// skip creation of the given directory if it
 /// already exists in the file system
 /// </param>
 /// <exception cref="System.IO.IOException">
 /// if creation of
 /// <code>d</code>
 /// fails. This may occur if
 /// <code>d</code>
 /// did exist when the method was called. This can therefore
 /// cause IOExceptions during race conditions when multiple
 /// concurrent threads all try to create the same directory.
 /// </exception>
 public static void Mkdir(FilePath d, bool skipExisting)
 {
     if (!d.Mkdir())
     {
         if (skipExisting && d.IsDirectory())
         {
             return;
         }
         throw new IOException(MessageFormat.Format(JGitText.Get().mkDirFailed, d.GetAbsolutePath
             ()));
     }
 }
开发者ID:kenji-tan,项目名称:ngit,代码行数:30,代码来源:FileUtils.cs

示例11: RenameAndOpenPack

		/// <exception cref="System.IO.IOException"></exception>
		private PackLock RenameAndOpenPack(string lockMessage)
		{
			if (!keepEmpty && GetObjectCount() == 0)
			{
				CleanupTemporaryFiles();
				return null;
			}
			MessageDigest d = Constants.NewMessageDigest();
			byte[] oeBytes = new byte[Constants.OBJECT_ID_LENGTH];
			for (int i = 0; i < GetObjectCount(); i++)
			{
				PackedObjectInfo oe = GetObject(i);
				oe.CopyRawTo(oeBytes, 0);
				d.Update(oeBytes);
			}
			string name = ObjectId.FromRaw(d.Digest()).Name;
			FilePath packDir = new FilePath(db.GetDirectory(), "pack");
			FilePath finalPack = new FilePath(packDir, "pack-" + name + ".pack");
			FilePath finalIdx = new FilePath(packDir, "pack-" + name + ".idx");
			PackLock keep = new PackLock(finalPack, db.GetFS());
			if (!packDir.Exists() && !packDir.Mkdir() && !packDir.Exists())
			{
				// The objects/pack directory isn't present, and we are unable
				// to create it. There is no way to move this pack in.
				//
				CleanupTemporaryFiles();
				throw new IOException(MessageFormat.Format(JGitText.Get().cannotCreateDirectory, 
					packDir.GetAbsolutePath()));
			}
			if (finalPack.Exists())
			{
				// If the pack is already present we should never replace it.
				//
				CleanupTemporaryFiles();
				return null;
			}
			if (lockMessage != null)
			{
				// If we have a reason to create a keep file for this pack, do
				// so, or fail fast and don't put the pack in place.
				//
				try
				{
					if (!keep.Lock(lockMessage))
					{
						throw new IOException(MessageFormat.Format(JGitText.Get().cannotLockPackIn, finalPack
							));
					}
				}
				catch (IOException e)
				{
					CleanupTemporaryFiles();
					throw;
				}
			}
			if (!tmpPack.RenameTo(finalPack))
			{
				CleanupTemporaryFiles();
				keep.Unlock();
				throw new IOException(MessageFormat.Format(JGitText.Get().cannotMovePackTo, finalPack
					));
			}
			if (!tmpIdx.RenameTo(finalIdx))
			{
				CleanupTemporaryFiles();
				keep.Unlock();
				if (!finalPack.Delete())
				{
					finalPack.DeleteOnExit();
				}
				throw new IOException(MessageFormat.Format(JGitText.Get().cannotMoveIndexTo, finalIdx
					));
			}
			try
			{
				newPack = db.OpenPack(finalPack, finalIdx);
			}
			catch (IOException err)
			{
				keep.Unlock();
				if (finalPack.Exists())
				{
					FileUtils.Delete(finalPack);
				}
				if (finalIdx.Exists())
				{
					FileUtils.Delete(finalIdx);
				}
				throw;
			}
			return lockMessage != null ? keep : null;
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:93,代码来源:ObjectDirectoryPackParser.cs

示例12: TestDiffTwoCommits

 public virtual void TestDiffTwoCommits()
 {
     Write(new FilePath(db.WorkTree, "test.txt"), "test");
     FilePath folder = new FilePath(db.WorkTree, "folder");
     folder.Mkdir();
     Write(new FilePath(folder, "folder.txt"), "folder");
     Git git = new Git(db);
     git.Add().AddFilepattern(".").Call();
     git.Commit().SetMessage("Initial commit").Call();
     Write(new FilePath(folder, "folder.txt"), "folder change");
     git.Add().AddFilepattern(".").Call();
     git.Commit().SetMessage("second commit").Call();
     Write(new FilePath(folder, "folder.txt"), "second folder change");
     git.Add().AddFilepattern(".").Call();
     git.Commit().SetMessage("third commit").Call();
     // bad filter
     DiffCommand diff = git.Diff().SetShowNameAndStatusOnly(true).SetPathFilter(PathFilter
         .Create("test.txt")).SetOldTree(GetTreeIterator("HEAD^^")).SetNewTree(GetTreeIterator
         ("HEAD^"));
     IList<DiffEntry> entries = diff.Call();
     NUnit.Framework.Assert.AreEqual(0, entries.Count);
     // no filter, two commits
     OutputStream @out = new ByteArrayOutputStream();
     diff = git.Diff().SetOutputStream(@out).SetOldTree(GetTreeIterator("HEAD^^")).SetNewTree
         (GetTreeIterator("HEAD^"));
     entries = diff.Call();
     NUnit.Framework.Assert.AreEqual(1, entries.Count);
     NUnit.Framework.Assert.AreEqual(DiffEntry.ChangeType.MODIFY, entries[0].GetChangeType
         ());
     NUnit.Framework.Assert.AreEqual("folder/folder.txt", entries[0].GetOldPath());
     NUnit.Framework.Assert.AreEqual("folder/folder.txt", entries[0].GetNewPath());
     string actual = @out.ToString();
     string expected = "diff --git a/folder/folder.txt b/folder/folder.txt\n" + "index 0119635..95c4c65 100644\n"
          + "--- a/folder/folder.txt\n" + "+++ b/folder/folder.txt\n" + "@@ -1 +1 @@\n" +
          "-folder\n" + "\\ No newline at end of file\n" + "+folder change\n" + "\\ No newline at end of file\n";
     NUnit.Framework.Assert.AreEqual(expected.ToString(), actual);
 }
开发者ID:JamesChan,项目名称:ngit,代码行数:37,代码来源:DiffCommandTest.cs

示例13: RelativeGitDirRef

		public virtual void RelativeGitDirRef()
		{
			FileRepository repo1 = CreateWorkRepository();
			FilePath dir = new FilePath(repo1.WorkTree, "dir");
			NUnit.Framework.Assert.IsTrue(dir.Mkdir());
			FilePath dotGit = new FilePath(dir, Constants.DOT_GIT);
			new FileWriter(dotGit).Append("gitdir: ../" + Constants.DOT_GIT).Close();
			FileRepositoryBuilder builder = new FileRepositoryBuilder();
			builder.SetWorkTree(dir);
			builder.SetMustExist(true);
			FileRepository repo2 = builder.Build();
			NUnit.Framework.Assert.AreEqual(repo1.Directory, repo2.Directory);
			NUnit.Framework.Assert.AreEqual(dir, repo2.WorkTree);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:14,代码来源:FileRepositoryBuilderTest.cs


注:本文中的Sharpen.FilePath.Mkdir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。