Beispiel #1
0
        /// <summary>
        /// Load from URL.
        /// </summary>
        /// <param name="d">Destination path.</param>
        /// <param name="s">Source URL.</param>
        private static void LoadUrl(string d, string s)
        {
            var t = File0.Temp(GetName(s));

            new WebClient().DownloadFile(s, t);
            LoadFile(d, t, true);
        }
Beispiel #2
0
        /// <summary>
        /// Set link description.
        /// </summary>
        /// <param name="l">Link path.</param>
        /// <param name="d">Link description.</param>
        public static void SetDescription(string l, string d)
        {
            var v = File0.ReadAllLines(l);

            if (v.Length > 0)
            {
                v[0] = string.Format(":: {0}", d);
            }
            File.WriteAllLines(l, v);
        }
Beispiel #3
0
        /// <summary>
        /// Set target path.
        /// </summary>
        /// <param name="l">Link path.</param>
        /// <param name="t">Target path.</param>
        public static void SetTarget(string l, string t)
        {
            var v = File0.ReadAllLines(l);

            if (v.Length > 1)
            {
                v[1] = string.Format("@\"{0}\" %*", t);
            }
            File.WriteAllLines(l, v);
        }
Beispiel #4
0
        /// <summary>
        /// Load from source Zip.
        /// </summary>
        /// <param name="d">Destination path.</param>
        /// <param name="s">Source path.</param>
        /// <param name="r">Remove source?</param>
        private static void LoadZip(string d, string s, bool r = false)
        {
            var t = File0.Temp();

            Directory0.Create(t);
            ZipFile.ExtractToDirectory(s, t);
            LoadDirectory(d, t, true);
            if (r)
            {
                File.Delete(s);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Load from source directory.
        /// </summary>
        /// <param name="d">Destination path.</param>
        /// <param name="s">Source path.</param>
        /// <param name="r">Remove source?</param>
        private static void LoadDirectory(string d, string s, bool r = false)
        {
            var t = File0.Temp();

            if (r)
            {
                Directory.Move(s, t);
            }
            else
            {
                Directory0.Copy(s, t, true);
            }
            Directory.Move(Directory0.NonEmpty(t), d);
            Directory0.Delete(Path.Combine(d, ".git"), true);
            Directory0.Delete(t, true);
        }
Beispiel #6
0
 /// <summary>
 /// Get module source.
 /// </summary>
 /// <param name="m">Module path.</param>
 /// <returns>Source paths.</returns>
 public static IList <string> GetSource(string m)
 {
     return(File0.ReadAllLines(m + ".source"));
 }
Beispiel #7
0
 /// <summary>
 /// Destroy module.
 /// </summary>
 /// <param name="m">Module path.</param>
 public static void Destroy(string m)
 {
     Directory0.Delete(m);
     File0.Delete(m + ".source");
     File0.Delete(m + ".target");
 }
Beispiel #8
0
 /// <summary>
 /// Get module target.
 /// </summary>
 /// <param name="m">Module path.</param>
 /// <returns>Target paths.</returns>
 public static IList <string> GetTarget(string m)
 {
     return(File0.ReadAllLines(m + ".target"));
 }
Beispiel #9
0
        /// <summary>
        /// Get link description.
        /// </summary>
        /// <param name="l">Link path.</param>
        /// <returns>Link description.</returns>
        public static string GetDescription(string l)
        {
            var v = File0.ReadAllLines(l);

            return(v.Length > 0 && v[0].Length > 3 ? v[0].Substring(3) : "");
        }
Beispiel #10
0
 /// <summary>
 /// Destroy link.
 /// </summary>
 /// <param name="l">Link path.</param>
 public static void Destroy(string l)
 {
     File0.Delete(l);
 }
Beispiel #11
0
        /// <summary>
        /// Get target path.
        /// </summary>
        /// <param name="l">Link path.</param>
        /// <returns>Target path.</returns>
        public static string GetTarget(string l)
        {
            var v = File0.ReadAllLines(l);

            return(v.Length > 1 && v[1].Length > 6 ? v[1].Substring(2, v[1].Length - 6) : "");
        }