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


C# FilePath.GetParentFile方法代码示例

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


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

示例1: DiscoverGitPrefix

		protected internal override FilePath DiscoverGitPrefix()
		{
			string path = SystemReader.GetInstance().Getenv("PATH");
			FilePath gitExe = SearchPath(path, "git");
			if (gitExe != null)
			{
				return gitExe.GetParentFile().GetParentFile();
			}
			if (SystemReader.GetInstance().IsMacOS())
			{
				// On MacOSX, PATH is shorter when Eclipse is launched from the
				// Finder than from a terminal. Therefore try to launch bash as a
				// login shell and search using that.
				//
				string w = ReadPipe(UserHome(), new string[] { "bash", "--login", "-c", "which git"
					 }, Encoding.Default.Name());
				//
				//
				if (w == null || w.Length == 0)
				{
					return null;
				}
				FilePath parentFile = new FilePath(w).GetParentFile();
				if (parentFile == null)
				{
					return null;
				}
				return parentFile.GetParentFile();
			}
			return null;
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:31,代码来源:FS_POSIX.cs

示例2: PackLock

		/// <summary>Create a new lock for a pack file.</summary>
		/// <remarks>Create a new lock for a pack file.</remarks>
		/// <param name="packFile">location of the <code>pack-*.pack</code> file.</param>
		/// <param name="fs">the filesystem abstraction used by the repository.</param>
		public PackLock(FilePath packFile, FS fs)
		{
			FilePath p = packFile.GetParentFile();
			string n = packFile.GetName();
			keepFile = new FilePath(p, Sharpen.Runtime.Substring(n, 0, n.Length - 5) + ".keep"
				);
			this.fs = fs;
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:12,代码来源:PackLock.cs

示例3: SetUp

 public override void SetUp()
 {
     base.SetUp();
     home = new FilePath(trash, "home");
     FileUtils.Mkdir(home);
     configFile = new FilePath(new FilePath(home, ".ssh"), Constants.CONFIG);
     FileUtils.Mkdir(configFile.GetParentFile());
     Runtime.SetProperty("user.name", "jex_junit");
     osc = new OpenSshConfig(home, configFile);
 }
开发者ID:JamesChan,项目名称:ngit,代码行数:10,代码来源:OpenSshConfigTest.cs

示例4: OpenAlternate

		/// <exception cref="System.IO.IOException"></exception>
		private FileObjectDatabase.AlternateHandle OpenAlternate(FilePath objdir)
		{
			FilePath parent = objdir.GetParentFile();
			if (RepositoryCache.FileKey.IsGitRepository(parent, fs))
			{
				RepositoryCache.FileKey key = RepositoryCache.FileKey.Exact(parent, fs);
				FileRepository db = (FileRepository)RepositoryCache.Open(key);
				return new FileObjectDatabase.AlternateRepository(db);
			}
			NGit.Storage.File.ObjectDirectory db_1 = new NGit.Storage.File.ObjectDirectory(config
				, objdir, null, fs);
			return new FileObjectDatabase.AlternateHandle(db_1);
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:14,代码来源:ObjectDirectory.cs

示例5: Add

		public override void Add(HostKey hostkey, UserInfo userinfo)
		{
			int type = hostkey.type;
			string host = hostkey.GetHost();
			byte[] key = hostkey.key;
			HostKey hk = null;
			lock (pool)
			{
				for (int i = 0; i < pool.Count; i++)
				{
					hk = (HostKey)(pool[i]);
					if (hk.IsMatched(host) && hk.type == type)
					{
					}
				}
			}
			hk = hostkey;
			pool.Add(hk);
			string bar = GetKnownHostsRepositoryID();
			if (bar != null)
			{
				bool foo = true;
				FilePath goo = new FilePath(bar);
				if (!goo.Exists())
				{
					foo = false;
					if (userinfo != null)
					{
						foo = userinfo.PromptYesNo(bar + " does not exist.\n" + "Are you sure you want to create it?"
							);
						goo = goo.GetParentFile();
						if (foo && goo != null && !goo.Exists())
						{
							foo = userinfo.PromptYesNo("The parent directory " + goo + " does not exist.\n" +
								 "Are you sure you want to create it?");
							if (foo)
							{
								if (!goo.Mkdirs())
								{
									userinfo.ShowMessage(goo + " has not been created.");
									foo = false;
								}
								else
								{
									userinfo.ShowMessage(goo + " has been succesfully created.\nPlease check its access permission."
										);
								}
							}
						}
						if (goo == null)
						{
							foo = false;
						}
					}
				}
				if (foo)
				{
					try
					{
						Sync(bar);
					}
					catch (Exception e)
					{
						System.Console.Error.WriteLine("sync known_hosts: " + e);
					}
				}
			}
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:68,代码来源:KnownHosts.cs

示例6: SetupReflog

		/// <exception cref="System.IO.FileNotFoundException"></exception>
		/// <exception cref="System.IO.IOException"></exception>
		private void SetupReflog(string logName, byte[] data)
		{
			FilePath logfile = new FilePath(db.Directory, logName);
			if (!logfile.GetParentFile().Mkdirs() && !logfile.GetParentFile().IsDirectory())
			{
				throw new IOException("oops, cannot create the directory for the test reflog file"
					 + logfile);
			}
			FileOutputStream fileOutputStream = new FileOutputStream(logfile);
			try
			{
				fileOutputStream.Write(data);
			}
			finally
			{
				fileOutputStream.Close();
			}
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:20,代码来源:ReflogReaderTest.cs

示例7: Test000_openrepo_alternate_index_file_and_objdirs

 public virtual void Test000_openrepo_alternate_index_file_and_objdirs()
 {
     FilePath repo1Parent = new FilePath(trash.GetParentFile(), "r1");
     FilePath indexFile = new FilePath(trash, "idx");
     FilePath objDir = new FilePath(trash, "../obj");
     FilePath altObjDir = ((ObjectDirectory)db.ObjectDatabase).GetDirectory();
     Repository repo1initial = new FileRepository(new FilePath(repo1Parent, Constants.
         DOT_GIT));
     repo1initial.Create();
     repo1initial.Close();
     FilePath theDir = new FilePath(repo1Parent, Constants.DOT_GIT);
     FileRepository r = new FileRepositoryBuilder().SetGitDir(theDir).SetObjectDirectory
         (objDir).AddAlternateObjectDirectory(altObjDir).SetIndexFile(indexFile).Build();
     //
     //
     //
     //
     AssertEqualsPath(theDir, r.Directory);
     AssertEqualsPath(theDir.GetParentFile(), r.WorkTree);
     AssertEqualsPath(indexFile, r.GetIndexFile());
     AssertEqualsPath(objDir, ((ObjectDirectory)r.ObjectDatabase).GetDirectory());
     NUnit.Framework.Assert.IsNotNull(r.Open(ObjectId.FromString("6db9c2ebf75590eef973081736730a9ea169a0c4"
         )));
     // Must close or the default repo pack files created by this test gets
     // locked via the alternate object directories on Windows.
     r.Close();
 }
开发者ID:JamesChan,项目名称:ngit,代码行数:27,代码来源:T0003_BasicTest.cs

示例8: RepositoryWithRootLevelSubmoduleRelativeRef

		public virtual void RepositoryWithRootLevelSubmoduleRelativeRef()
		{
			ObjectId id = ObjectId.FromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
			string path = "sub";
			FilePath dotGit = new FilePath(db.WorkTree, path + FilePath.separatorChar + Constants
				.DOT_GIT);
			if (!dotGit.GetParentFile().Exists())
			{
				dotGit.GetParentFile().Mkdirs();
			}
			FilePath modulesGitDir = new FilePath(db.Directory, "modules" + FilePath.separatorChar
				 + path);
			new FileWriter(dotGit).Append("gitdir: " + "../" + Constants.DOT_GIT + "/modules/"
				 + path).Close();
			FileRepositoryBuilder builder = new FileRepositoryBuilder();
			builder.SetWorkTree(new FilePath(db.WorkTree, path));
			builder.Build().Create();
			DirCache cache = db.LockDirCache();
			DirCacheEditor editor = cache.Editor();
			editor.Add(new _PathEdit_203(id, path));
			editor.Commit();
			SubmoduleWalk gen = SubmoduleWalk.ForIndex(db);
			NUnit.Framework.Assert.IsTrue(gen.Next());
			NUnit.Framework.Assert.AreEqual(path, gen.GetPath());
			NUnit.Framework.Assert.AreEqual(id, gen.GetObjectId());
			NUnit.Framework.Assert.AreEqual(new FilePath(db.WorkTree, path), gen.GetDirectory
				());
			NUnit.Framework.Assert.IsNull(gen.GetConfigUpdate());
			NUnit.Framework.Assert.IsNull(gen.GetConfigUrl());
			NUnit.Framework.Assert.IsNull(gen.GetModulesPath());
			NUnit.Framework.Assert.IsNull(gen.GetModulesUpdate());
			NUnit.Framework.Assert.IsNull(gen.GetModulesUrl());
			Repository subRepo = gen.GetRepository();
			AddRepoToClose(subRepo);
			NUnit.Framework.Assert.IsNotNull(subRepo);
			NUnit.Framework.Assert.AreEqual(modulesGitDir, subRepo.Directory);
			NUnit.Framework.Assert.AreEqual(new FilePath(db.WorkTree, path), subRepo.WorkTree
				);
			NUnit.Framework.Assert.IsFalse(gen.Next());
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:40,代码来源:SubmoduleWalkTest.cs

示例9: Write

 /// <summary>Write a string as a UTF-8 file.</summary>
 /// <remarks>Write a string as a UTF-8 file.</remarks>
 /// <param name="f">
 /// file to write the string to. Caller is responsible for making
 /// sure it is in the trash directory or will otherwise be cleaned
 /// up at the end of the test. If the parent directory does not
 /// exist, the missing parent directories are automatically
 /// created.
 /// </param>
 /// <param name="body">content to write to the file.</param>
 /// <exception cref="System.IO.IOException">the file could not be written.</exception>
 public static void Write(FilePath f, string body)
 {
     FileUtils.Mkdirs(f.GetParentFile(), true);
     TextWriter w = new OutputStreamWriter(new FileOutputStream(f), "UTF-8");
     try
     {
         w.Write(body);
     }
     finally
     {
         w.Close();
     }
 }
开发者ID:ArsenShnurkov,项目名称:ngit,代码行数:24,代码来源:JGitTestUtil.cs

示例10: DoCheckout

 /// <exception cref="NGit.Errors.CorruptObjectException"></exception>
 /// <exception cref="System.IO.IOException"></exception>
 /// <exception cref="NGit.Errors.MissingObjectException"></exception>
 /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
 /// <exception cref="NGit.Errors.CheckoutConflictException"></exception>
 /// <exception cref="NGit.Errors.IndexWriteException"></exception>
 private bool DoCheckout()
 {
     toBeDeleted.Clear();
     ObjectReader objectReader = repo.ObjectDatabase.NewReader();
     try
     {
         if (headCommitTree != null)
         {
             PreScanTwoTrees();
         }
         else
         {
             PrescanOneTree();
         }
         if (!conflicts.IsEmpty())
         {
             if (failOnConflict)
             {
                 throw new NGit.Errors.CheckoutConflictException(Sharpen.Collections.ToArray(conflicts
                     , new string[conflicts.Count]));
             }
             else
             {
                 CleanUpConflicts();
             }
         }
         // update our index
         builder.Finish();
         FilePath file = null;
         string last = string.Empty;
         // when deleting files process them in the opposite order as they have
         // been reported. This ensures the files are deleted before we delete
         // their parent folders
         for (int i = removed.Count - 1; i >= 0; i--)
         {
             string r = removed[i];
             file = new FilePath(repo.WorkTree, r);
             if (!file.Delete() && file.Exists())
             {
                 // The list of stuff to delete comes from the index
                 // which will only contain a directory if it is
                 // a submodule, in which case we shall not attempt
                 // to delete it. A submodule is not empty, so it
                 // is safe to check this after a failed delete.
                 if (!file.IsDirectory())
                 {
                     toBeDeleted.AddItem(r);
                 }
             }
             else
             {
                 if (!IsSamePrefix(r, last))
                 {
                     RemoveEmptyParents(new FilePath(repo.WorkTree, last));
                 }
                 last = r;
             }
         }
         if (file != null)
         {
             RemoveEmptyParents(file);
         }
         foreach (string path in updated.Keys)
         {
             // ... create/overwrite this file ...
             file = new FilePath(repo.WorkTree, path);
             if (!file.GetParentFile().Mkdirs())
             {
             }
             // ignore
             DirCacheEntry entry = dc.GetEntry(path);
             // submodules are handled with separate operations
             if (FileMode.GITLINK.Equals(entry.RawMode))
             {
                 continue;
             }
             CheckoutEntry(repo, file, entry, objectReader);
         }
         // commit the index builder - a new index is persisted
         if (!builder.Commit())
         {
             throw new IndexWriteException();
         }
     }
     finally
     {
         objectReader.Release();
     }
     return toBeDeleted.Count == 0;
 }
开发者ID:stinos,项目名称:ngit,代码行数:96,代码来源:DirCacheCheckout.cs

示例11: LockFile

		/// <summary>Create a new lock for any file.</summary>
		/// <remarks>Create a new lock for any file.</remarks>
		/// <param name="f">the file that will be locked.</param>
		/// <param name="fs">
		/// the file system abstraction which will be necessary to perform
		/// certain file system operations.
		/// </param>
		public LockFile(FilePath f, FS fs)
		{
			@ref = f;
			lck = new FilePath(@ref.GetParentFile(), @ref.GetName() + SUFFIX);
			this.fs = fs;
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:13,代码来源:LockFile.cs

示例12: Checkout

		/// <summary>Execute this checkout</summary>
		/// <returns>
		/// <code>false</code> if this method could not delete all the files
		/// which should be deleted (e.g. because of of the files was
		/// locked). In this case
		/// <see cref="GetToBeDeleted()">GetToBeDeleted()</see>
		/// lists the files
		/// which should be tried to be deleted outside of this method.
		/// Although <code>false</code> is returned the checkout was
		/// successful and the working tree was updated for all other files.
		/// <code>true</code> is returned when no such problem occurred
		/// </returns>
		/// <exception cref="System.IO.IOException">System.IO.IOException</exception>
		public virtual bool Checkout()
		{
			toBeDeleted.Clear();
			if (headCommitTree != null)
			{
				PreScanTwoTrees();
			}
			else
			{
				PrescanOneTree();
			}
			if (!conflicts.IsEmpty())
			{
				if (failOnConflict)
				{
					dc.Unlock();
					throw new CheckoutConflictException(Sharpen.Collections.ToArray(conflicts, new string
						[conflicts.Count]));
				}
				else
				{
					CleanUpConflicts();
				}
			}
			// update our index
			builder.Finish();
			FilePath file = null;
			string last = string.Empty;
			// when deleting files process them in the opposite order as they have
			// been reported. This ensures the files are deleted before we delete
			// their parent folders
			for (int i = removed.Count - 1; i >= 0; i--)
			{
				string r = removed[i];
				file = new FilePath(repo.WorkTree, r);
				if (!file.Delete() && file.Exists())
				{
					toBeDeleted.AddItem(r);
				}
				else
				{
					if (!IsSamePrefix(r, last))
					{
						RemoveEmptyParents(file);
					}
					last = r;
				}
			}
			if (file != null)
			{
				RemoveEmptyParents(file);
			}
			foreach (string path in updated.Keys)
			{
				// ... create/overwrite this file ...
				file = new FilePath(repo.WorkTree, path);
				file.GetParentFile().Mkdirs();
				file.CreateNewFile();
				DirCacheEntry entry = dc.GetEntry(path);
				CheckoutEntry(repo, file, entry);
			}
			// commit the index builder - a new index is persisted
			if (!builder.Commit())
			{
				dc.Unlock();
				throw new IndexWriteException();
			}
			return toBeDeleted.Count == 0;
		}
开发者ID:nickname100,项目名称:monodevelop,代码行数:82,代码来源:DirCacheCheckout.cs

示例13: Rename

 private static bool Rename(FilePath src, FilePath dst)
 {
     if (src.RenameTo(dst))
     {
         return true;
     }
     FilePath dir = dst.GetParentFile();
     if ((dir.Exists() || !dir.Mkdirs()) && !dir.IsDirectory())
     {
         return false;
     }
     return src.RenameTo(dst);
 }
开发者ID:sharwell,项目名称:ngit,代码行数:13,代码来源:RefDirectoryRename.cs

示例14: IndexPack

		/// <summary>Create a new pack indexer utility.</summary>
		/// <remarks>Create a new pack indexer utility.</remarks>
		/// <param name="db"></param>
		/// <param name="src">
		/// stream to read the pack data from. If the stream is buffered
		/// use
		/// <see cref="BUFFER_SIZE">BUFFER_SIZE</see>
		/// as the buffer size for the stream.
		/// </param>
		/// <param name="dstBase"></param>
		/// <exception cref="System.IO.IOException">the output packfile could not be created.
		/// 	</exception>
		public IndexPack(Repository db, InputStream src, FilePath dstBase)
		{
			repo = db;
			objectDatabase = db.ObjectDatabase.NewCachedDatabase();
			@in = src;
			inflater = new IndexPack.InflaterStream(this);
			readCurs = objectDatabase.NewReader();
			buf = new byte[BUFFER_SIZE];
			readBuffer = new byte[BUFFER_SIZE];
			objectDigest = Constants.NewMessageDigest();
			tempObjectId = new MutableObjectId();
			packDigest = Constants.NewMessageDigest();
			if (dstBase != null)
			{
				FilePath dir = dstBase.GetParentFile();
				string nam = dstBase.GetName();
				dstPack = new FilePath(dir, nam + ".pack");
				dstIdx = new FilePath(dir, nam + ".idx");
				packOut = new RandomAccessFile(dstPack, "rw");
				packOut.SetLength(0);
			}
			else
			{
				dstPack = null;
				dstIdx = null;
			}
		}
开发者ID:nickname100,项目名称:monodevelop,代码行数:39,代码来源:IndexPack.cs

示例15: RemoveEmptyParents

		private void RemoveEmptyParents(FilePath f)
		{
			FilePath parentFile = f.GetParentFile();
			while (!parentFile.Equals(root))
			{
				if (parentFile.List().Length == 0)
				{
					parentFile.Delete();
				}
				else
				{
					break;
				}
				parentFile = parentFile.GetParentFile();
			}
		}
开发者ID:stewartwhaley,项目名称:monodevelop,代码行数:16,代码来源:WorkDirCheckout.cs


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