GetParent() public method

public GetParent ( ) : string
return string
Ejemplo n.º 1
0
		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;
		}
Ejemplo n.º 2
0
		/// <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());
					}
				}
			}
		}