Exemple #1
0
        /// <summary>
        /// Store a copy of given file.
        /// </summary>
        /// <param name="fi"></param>
        /// <param name="PseudoLocation"></param>
        public static void StoreCpy(FileInfo fi, string PseudoLocation)
        {
            PseudoLocation = UnifyPseudoLocation(PseudoLocation);
            var installation = Installation00.GetInstallation();
            var fileID       = Guid.NewGuid();

            {
                var index = Get(PseudoLocation);
                if (index != null)
                {
                    File.Copy(fi.FullName, index.RealLocation, true);
                    return;
                }
            }
            if (installation == Installation.Empty)
            {
                installation          = new Installation();
                installation.FolderID = Guid.NewGuid().ToString();
                installation.Modified = true;
                var folder = Path.Combine(BasePath, installation.FolderID);
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                var   f     = fi.CopyTo(Path.Combine(folder, fileID.ToString()));
                Index index = new Index();
                index.RealLocation   = f.Name;
                index.PseudoLocation = PseudoLocation;
                installation.Indices.Add(index);
                Installation00.PresentingInstallations.Add(installation);
                TheArk.Installations.Add(installation.FolderID);
                SaveIndeics();
            }
            else
            {
                installation.Modified = true;
                var   folder = Path.Combine(BasePath, installation.FolderID);
                var   f      = fi.CopyTo(Path.Combine(folder, fileID.ToString()));
                Index index  = new Index();
                index.RealLocation   = f.Name;
                index.PseudoLocation = PseudoLocation;
                installation.Indices.Add(index);
            }
        }
Exemple #2
0
        /// <summary>
        /// Store a reference to given file.
        /// </summary>
        /// <param name="fi"></param>
        /// <param name="PseudoLocation"></param>
        public static void StoreRef(FileInfo fi, string PseudoLocation)
        {
            var installation = Installation00.GetInstallation();
            var fileID       = Guid.NewGuid();

            PseudoLocation = UnifyPseudoLocation(PseudoLocation);
            var i = Get(PseudoLocation);

            if (i is not null)
            {
                i.RealLocation = fi.FullName;
            }
            else
            if (installation == Installation.Empty)
            {
                installation          = new Installation();
                installation.FolderID = Guid.NewGuid().ToString();
                installation.Modified = true;
                var folder = Path.Combine(BasePath, installation.FolderID);
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                Index index = new Index();
                index.RealLocation   = fi.FullName;
                index.PseudoLocation = PseudoLocation;
                installation.Indices.Add(index);
                Installation00.PresentingInstallations.Add(installation);
                TheArk.Installations.Add(installation.FolderID);
                SaveIndeics();
            }
            else
            {
                installation.Modified = true;
                Index index = new Index();
                index.RealLocation   = fi.FullName;
                index.PseudoLocation = PseudoLocation;
                installation.Indices.Add(index);
            }
        }