Example #1
0
        public string GetDirectory(DeployContext ctx, string folderId)
        {
            switch (folderId)
            {
            case TargetDirectory.ProgramFiles:
                return(Path.Combine(ctx.GetDirectory(TargetDirectory.ProgramFilesRoot), appName));

            case TargetDirectory.CommonApplicationData:
                return(Path.Combine(ctx.GetDirectory(TargetDirectory.ProgramFilesRoot), appName));
            }

            if (ctx.Platform == "Linux" || ctx.Platform == "Unix")
            {
                string prefix = ctx.Prefix;
                if (prefix == null)
                {
                    prefix = "/usr/local";
                }
                switch (folderId)
                {
                case TargetDirectory.ProgramFilesRoot:
                    return(Path.Combine(prefix, "lib"));

                case TargetDirectory.CommonApplicationDataRoot:
                    return(Path.Combine(prefix, "share"));

                case TargetDirectory.Binaries:
                    return(Path.Combine(prefix, "bin"));

                case TargetDirectory.IncludeRoot:
                    return(Path.Combine(prefix, "include"));

                case TargetDirectory.Include:
                    return(Path.Combine(ctx.GetDirectory(TargetDirectory.IncludeRoot), appName));
                }
            }
            else if (ctx.Platform == "Windows")
            {
                switch (folderId)
                {
                case TargetDirectory.ProgramFilesRoot:
                    return(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));

                case TargetDirectory.Binaries:
                    return(Path.Combine(ctx.GetDirectory(TargetDirectory.ProgramFilesRoot), appName));

                case TargetDirectory.CommonApplicationDataRoot:
                    return(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData));
                }
            }
            return(null);
        }
Example #2
0
        internal static string ProcessFileTemplate(DeployContext ctx, string file)
        {
            TextFile      tf      = TextFile.ReadFile(file);
            string        text    = tf.Text;
            StringBuilder sb      = new StringBuilder();
            int           lastPos = 0;
            int           pos     = text.IndexOf('@');

            while (pos != -1)
            {
                int ep = text.IndexOf('@', pos + 1);
                if (ep == -1)
                {
                    break;
                }
                string tag = text.Substring(pos + 1, ep - pos - 1);
                string dir = ctx.GetDirectory(tag);
                if (dir != null)
                {
                    sb.Append(text, lastPos, pos - lastPos);
                    sb.Append(dir);
                    lastPos = ep + 1;
                }
                pos = text.IndexOf('@', ep + 1);
            }
            sb.Append(text, lastPos, text.Length - lastPos);
            string tmp = ctx.CreateTempFile();

            TextFile.WriteFile(tmp, sb.ToString(), tf.SourceEncoding);
            return(tmp);
        }
		internal static string ProcessFileTemplate (DeployContext ctx, string file)
		{
			TextFile tf = TextFile.ReadFile (file);
			string text = tf.Text;
			StringBuilder sb = new StringBuilder ();
			int lastPos = 0;
			int pos = text.IndexOf ('@');
			while (pos != -1) {
				int ep = text.IndexOf ('@', pos+1);
				if (ep == -1)
					break;
				string tag = text.Substring (pos + 1, ep - pos - 1);
				string dir = ctx.GetDirectory (tag);
				if (dir != null) {
					sb.Append (text, lastPos, pos - lastPos);
					sb.Append (dir);
					lastPos = ep + 1;
				}
				pos = text.IndexOf ('@', ep+1);
			}
			sb.Append (text, lastPos, text.Length - lastPos);
			string tmp = ctx.CreateTempFile ();
			TextFile.WriteFile (tmp, sb.ToString (), tf.SourceEncoding);
			return tmp;
		}
		public string GetDirectory (DeployContext ctx, string folderId)
		{
			switch (folderId) {
			case TargetDirectory.ProgramFiles:
				return Path.Combine (ctx.GetDirectory (TargetDirectory.ProgramFilesRoot), appName);
			case TargetDirectory.CommonApplicationData:
				return Path.Combine (ctx.GetDirectory (TargetDirectory.ProgramFilesRoot), appName);
			}

			if (ctx.Platform == "Linux" || ctx.Platform == "Unix") {
				string prefix = ctx.Prefix;
				if (prefix == null)
					prefix = "/usr/local";
				switch (folderId) {
				case TargetDirectory.ProgramFilesRoot:
					return Path.Combine (prefix, "lib");
				case TargetDirectory.CommonApplicationDataRoot:
					return Path.Combine (prefix, "share");
				case TargetDirectory.Binaries:
					return Path.Combine (prefix, "bin");
				case TargetDirectory.IncludeRoot:
					return Path.Combine (prefix, "include");
				case TargetDirectory.Include:
					return Path.Combine (ctx.GetDirectory (TargetDirectory.IncludeRoot), appName);
				}
			}
			else if (ctx.Platform == "Windows") {
				switch (folderId) {
				case TargetDirectory.ProgramFilesRoot:
					return Environment.GetFolderPath (Environment.SpecialFolder.ProgramFiles);
				case TargetDirectory.Binaries:
					return Path.Combine (ctx.GetDirectory (TargetDirectory.ProgramFilesRoot), appName);
				case TargetDirectory.CommonApplicationDataRoot:
					return Environment.GetFolderPath (Environment.SpecialFolder.CommonApplicationData);
				}
			}
			return null;
		}
		public override string ResolveDirectory (DeployContext context, string folderId)
		{
			if (context.Platform == "Linux") {
				if (folderId == LinuxTargetDirectory.PkgConfig)
					return Path.Combine (context.GetDirectory (TargetDirectory.ProgramFilesRoot), "pkgconfig");
				if (folderId == LinuxTargetDirectory.DesktopApplications)
					return Path.Combine (context.GetDirectory (TargetDirectory.CommonApplicationDataRoot), "applications");
			}
			return base.ResolveDirectory (context, folderId);
		}