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


C# FilePath.IsFile方法代码示例

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


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

示例1: RunFileIfExists

		private static void RunFileIfExists(Context cx, Scriptable global, FilePath f)
		{
			if (f.IsFile())
			{
				Main.ProcessFileNoThrow(cx, global, f.GetPath());
			}
		}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:7,代码来源:ShellTest.cs

示例2: 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());
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:25,代码来源:T0003_BasicTest.cs

示例3: TestEmptyIfRootIsFile

		public virtual void TestEmptyIfRootIsFile()
		{
			FilePath r = new FilePath(trash, paths[0]);
			NUnit.Framework.Assert.IsTrue(r.IsFile());
			FileTreeIterator fti = new FileTreeIterator(r, db.FileSystem, ((FileBasedConfig)db
				.GetConfig()).Get(WorkingTreeOptions.KEY));
			NUnit.Framework.Assert.IsTrue(fti.First);
			NUnit.Framework.Assert.IsTrue(fti.Eof);
		}
开发者ID:shoff,项目名称:ngit,代码行数:9,代码来源:FileTreeIteratorTest.cs

示例4: 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());
					}
				}
			}
		}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:19,代码来源:ComplianceTest.cs

示例5: Test002_WriteEmptyTree2

 public virtual void Test002_WriteEmptyTree2()
 {
     // File shouldn't exist as it is in a test pack.
     //
     ObjectId treeId = InsertTree(new TreeFormatter());
     NUnit.Framework.Assert.AreEqual("4b825dc642cb6eb9a060e54bf8d69288fbee4904", treeId
         .Name);
     FilePath o = new FilePath(new FilePath(new FilePath(db.Directory, "objects"), "4b"
         ), "825dc642cb6eb9a060e54bf8d69288fbee4904");
     NUnit.Framework.Assert.IsFalse(o.IsFile(), "Exists " + o);
 }
开发者ID:JamesChan,项目名称:ngit,代码行数:11,代码来源:T0003_BasicTest.cs

示例6: Test002_WriteEmptyTree

 public virtual void Test002_WriteEmptyTree()
 {
     // One of our test packs contains the empty tree object. If the pack is
     // open when we create it we won't write the object file out as a loose
     // object (as it already exists in the pack).
     //
     Repository newdb = CreateBareRepository();
     ObjectInserter oi = newdb.NewObjectInserter();
     ObjectId treeId = oi.Insert(new TreeFormatter());
     oi.Release();
     NUnit.Framework.Assert.AreEqual("4b825dc642cb6eb9a060e54bf8d69288fbee4904", treeId
         .Name);
     FilePath o = new FilePath(new FilePath(new FilePath(newdb.Directory, "objects"),
         "4b"), "825dc642cb6eb9a060e54bf8d69288fbee4904");
     NUnit.Framework.Assert.IsTrue(o.IsFile(), "Exists " + o);
     NUnit.Framework.Assert.IsTrue(!o.CanWrite(), "Read-only " + o);
 }
开发者ID:JamesChan,项目名称:ngit,代码行数:17,代码来源:T0003_BasicTest.cs

示例7: ReadSource

		private string ReadSource(FilePath f)
		{
			string absPath = f.GetAbsolutePath();
			if (!f.IsFile())
			{
				AddError("msg.jsfile.not.found", absPath);
				return null;
			}
			try
			{
				return (string)SourceReader.ReadFileOrUrl(absPath, true, characterEncoding);
			}
			catch (FileNotFoundException)
			{
				AddError("msg.couldnt.open", absPath);
			}
			catch (IOException ioe)
			{
				AddFormatedError(ioe.ToString());
			}
			return null;
		}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:22,代码来源:Program.cs

示例8: AssertWorkDir

        /// <exception cref="NGit.Errors.CorruptObjectException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        public virtual void AssertWorkDir(Dictionary<string, string> i)
        {
            TreeWalk walk = new TreeWalk(db);
            walk.Recursive = true;
            walk.AddTree(new FileTreeIterator(db));
            string expectedValue;
            string path;
            int nrFiles = 0;
            FileTreeIterator ft;
            while (walk.Next())
            {
                ft = walk.GetTree<FileTreeIterator>(0);
                path = ft.EntryPathString;
                expectedValue = i.Get(path);
                NUnit.Framework.Assert.IsNotNull(expectedValue, "found unexpected file for path "
                     + path + " in workdir");
                FilePath file = new FilePath(db.WorkTree, path);
                NUnit.Framework.Assert.IsTrue(file.Exists());
                if (file.IsFile())
                {
                    FileInputStream @is = new FileInputStream(file);
                    byte[] buffer = new byte[(int)file.Length()];
                    int offset = 0;
                    int numRead = 0;
                    while (offset < buffer.Length && (numRead = @is.Read(buffer, offset, buffer.Length
                         - offset)) >= 0)
                    {
                        offset += numRead;
                    }
                    @is.Close();

                    CollectionAssert.AreEqual (buffer, Sharpen.Runtime.GetBytesForString(i.Get(path)),
                        "unexpected content for path " + path + " in workDir. ");
                    nrFiles++;
                }
            }
            NUnit.Framework.Assert.AreEqual(i.Count, nrFiles, "WorkDir has not the right size."
                );
        }
开发者ID:JamesChan,项目名称:ngit,代码行数:41,代码来源:DirCacheCheckoutTest.cs

示例9: PrescanTwoTrees

		/// <exception cref="System.IO.IOException"></exception>
		internal virtual void PrescanTwoTrees()
		{
			new IndexTreeWalker(index, head, merge, root, new _AbstractIndexTreeVisitor_267(this
				)).Walk();
			// if there's a conflict, don't list it under
			// to-be-removed, since that messed up our next
			// section
			removed.RemoveAll(conflicts);
			foreach (string path in updated.Keys)
			{
				if (index.GetEntry(path) == null)
				{
					FilePath file = new FilePath(root, path);
					if (file.IsFile())
					{
						conflicts.AddItem(path);
					}
					else
					{
						if (file.IsDirectory())
						{
							CheckConflictsWithFile(file);
						}
					}
				}
			}
			conflicts.RemoveAll(removed);
		}
开发者ID:stewartwhaley,项目名称:monodevelop,代码行数:29,代码来源:WorkDirCheckout.cs

示例10: VisitEntry

			/// <exception cref="System.IO.IOException"></exception>
			public override void VisitEntry(TreeEntry m, GitIndex.Entry i, FilePath file)
			{
				if (m != null)
				{
					if (!file.IsFile())
					{
						this._enclosing.CheckConflictsWithFile(file);
					}
				}
				else
				{
					if (file.Exists())
					{
						this._enclosing.removed.AddItem(i.GetName());
						this._enclosing.conflicts.Remove(i.GetName());
					}
				}
			}
开发者ID:stewartwhaley,项目名称:monodevelop,代码行数:19,代码来源:WorkDirCheckout.cs

示例11: LoadProperties

		/// <exception cref="System.NotSupportedException"></exception>
		private Properties LoadProperties()
		{
			if (local.Directory != null)
			{
				FilePath propsFile = new FilePath(local.Directory, uri.GetUser());
				if (propsFile.IsFile())
				{
					return LoadPropertiesFile(propsFile);
				}
			}
			FilePath propsFile_1 = new FilePath(local.FileSystem.UserHome(), uri.GetUser());
			if (propsFile_1.IsFile())
			{
				return LoadPropertiesFile(propsFile_1);
			}
			Properties props = new Properties();
			props.SetProperty("accesskey", uri.GetUser());
			props.SetProperty("secretkey", uri.GetPass());
			return props;
		}
开发者ID:nickname100,项目名称:monodevelop,代码行数:21,代码来源:TransportAmazonS3.cs

示例12: LoadIdentity

 private static void LoadIdentity(JSch sch, FilePath priv)
 {
     if (priv.IsFile())
     {
         try
         {
             sch.AddIdentity(priv.GetAbsolutePath());
         }
         catch (JSchException)
         {
         }
     }
 }
开发者ID:kenji-tan,项目名称:ngit,代码行数:13,代码来源:JschConfigSessionFactory.cs

示例13: Open

			/// <exception cref="System.IO.IOException"></exception>
			public override ObjectLoader Open(string path, ObjectId id)
			{
				FilePath p = new FilePath(root, path);
				if (!p.IsFile())
				{
					throw new FileNotFoundException(path);
				}
				return new _ObjectLoader_237(p);
			}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:10,代码来源:ContentSource.cs

示例14: RequireMain

		/// <summary>
		/// Calling this method establishes a module as being the main module of the
		/// program to which this require() instance belongs.
		/// </summary>
		/// <remarks>
		/// Calling this method establishes a module as being the main module of the
		/// program to which this require() instance belongs. The module will be
		/// loaded as if require()'d and its "module" property will be set as the
		/// "main" property of this require() instance. You have to call this method
		/// before the module has been loaded (that is, the call to this method must
		/// be the first to require the module and thus trigger its loading). Note
		/// that the main module will execute in its own scope and not in the global
		/// scope. Since all other modules see the global scope, executing the main
		/// module in the global scope would open it for tampering by other modules.
		/// </remarks>
		/// <param name="cx">the current context</param>
		/// <param name="mainModuleId">the ID of the main module</param>
		/// <returns>the "exports" property of the main module</returns>
		/// <exception cref="System.InvalidOperationException">
		/// if the main module is already loaded when
		/// required, or if this require() instance already has a different main
		/// module set.
		/// </exception>
		public virtual Scriptable RequireMain(Context cx, string mainModuleId)
		{
			if (this.mainModuleId != null)
			{
				if (!this.mainModuleId.Equals(mainModuleId))
				{
					throw new InvalidOperationException("Main module already set to " + this.mainModuleId);
				}
				return mainExports;
			}
			ModuleScript moduleScript;
			try
			{
				// try to get the module script to see if it is on the module path
				moduleScript = moduleScriptProvider.GetModuleScript(cx, mainModuleId, null, null, paths);
			}
			catch (Exception x)
			{
				throw;
			}
			catch (Exception x)
			{
				throw new Exception(x);
			}
			if (moduleScript != null)
			{
				mainExports = GetExportedModuleInterface(cx, mainModuleId, null, null, true);
			}
			else
			{
				if (!sandboxed)
				{
					Uri mainUri = null;
					// try to resolve to an absolute URI or file path
					try
					{
						mainUri = new Uri(mainModuleId);
					}
					catch (URISyntaxException)
					{
					}
					// fall through
					// if not an absolute uri resolve to a file path
					if (mainUri == null || !mainUri.IsAbsoluteUri)
					{
						FilePath file = new FilePath(mainModuleId);
						if (!file.IsFile())
						{
							throw ScriptRuntime.ThrowError(cx, nativeScope, "Module \"" + mainModuleId + "\" not found.");
						}
						mainUri = file.ToURI();
					}
					mainExports = GetExportedModuleInterface(cx, mainUri.ToString(), mainUri, null, true);
				}
			}
			this.mainModuleId = mainModuleId;
			return mainExports;
		}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:81,代码来源:Require.cs


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