本文整理汇总了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());
}
}
}
}