本文整理匯總了C#中Sharpen.FilePath.GetParent方法的典型用法代碼示例。如果您正苦於以下問題:C# FilePath.GetParent方法的具體用法?C# FilePath.GetParent怎麽用?C# FilePath.GetParent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sharpen.FilePath
的用法示例。
在下文中一共展示了FilePath.GetParent方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetOutputFile
private FilePath GetOutputFile(FilePath parentDir, string className)
{
string path = className.Replace('.', FilePath.separatorChar);
path = System.String.Concat(path, ".class");
FilePath f = new FilePath(parentDir, path);
string dirPath = f.GetParent();
if (dirPath != null)
{
FilePath dir = new FilePath(dirPath);
if (!dir.Exists())
{
dir.Mkdirs();
}
}
return f;
}
示例2: ProcessSource
/// <summary>Compile JavaScript source.</summary>
/// <remarks>Compile JavaScript source.</remarks>
public virtual void ProcessSource(string[] filenames)
{
for (int i = 0; i != filenames.Length; ++i)
{
string filename = filenames[i];
if (!filename.EndsWith(".js"))
{
AddError("msg.extension.not.js", filename);
return;
}
FilePath f = new FilePath(filename);
string source = ReadSource(f);
if (source == null)
{
return;
}
string mainClassName = targetName;
if (mainClassName == null)
{
string name = f.GetName();
string nojs = Sharpen.Runtime.Substring(name, 0, name.Length - 3);
mainClassName = GetClassName(nojs);
}
if (targetPackage.Length != 0)
{
mainClassName = targetPackage + "." + mainClassName;
}
object[] compiled = compiler.CompileToClassFiles(source, filename, 1, mainClassName);
if (compiled == null || compiled.Length == 0)
{
return;
}
FilePath targetTopDir = null;
if (destinationDir != null)
{
targetTopDir = new FilePath(destinationDir);
}
else
{
string parent = f.GetParent();
if (parent != null)
{
targetTopDir = new FilePath(parent);
}
}
for (int j = 0; j != compiled.Length; j += 2)
{
string className = (string)compiled[j];
byte[] bytes = (byte[])compiled[j + 1];
FilePath outfile = GetOutputFile(targetTopDir, className);
try
{
FileOutputStream os = new FileOutputStream(outfile);
try
{
os.Write(bytes);
}
finally
{
os.Close();
}
}
catch (IOException ioe)
{
AddFormatedError(ioe.ToString());
}
}
}
}