private ArchiveVersion1007 GetArchiveVersion()
        {
            ArchiveVersionInfo avInfo = new ArchiveVersionInfo("AVID.KSA.1", new Dictionary <string, string>(), AVRuleSet.BKG1007);

            avInfo.Medias.Add("AVID.KSA.1.1", @"C:\AVID.KSA.1.1");
            var av = new ArchiveVersion1007(avInfo, _fileSystem);

            return(av);
        }
Exemplo n.º 2
0
        public void GetRelativePathFromAbsolutePath()
        {
            Dictionary <string, string> AbsolutePaths = new Dictionary <string, string>();

            AbsolutePaths.Add(@"C:\AVID.KSA.1.1\Indices\tableIndex.xml", @"AVID.KSA.1.1\Indices\tableIndex.xml");
            AbsolutePaths.Add(@"C:\AVID.KSA.1\AVID.KSA.1.1\Indices\tableIndex.xml", @"AVID.KSA.1.1\Indices\tableIndex.xml");
            AbsolutePaths.Add(@"C:\AVID.KSA.1\AVID.KSA.1\AVID.KSA.1.1\Indices\tableIndex.xml", @"AVID.KSA.1.1\Indices\tableIndex.xml");


            foreach (var path in AbsolutePaths)
            {
                ArchiveVersionInfo avInfo = new ArchiveVersionInfo("AVID.KSA.1", new Dictionary <string, string>(), AVRuleSet.BKG1007);
                avInfo.Medias.Add("AVID.KSA.1.1", @"C:\");
                ArchiveVersion av = new ArchiveVersion1007(avInfo);

                Assert.AreEqual(path.Value, av.GetRelativeFilePath(path.Key));
            }
        }
        /// <summary>
        /// Checks wether a given folder is an archive version
        /// </summary>
        /// <param name="avInfo">Output for arhive version information</param>
        /// <param name="path">File path of the folder to be checked</param>
        /// <returns></returns>
        public bool TryGetAvFolder(out ArchiveVersionInfo avInfo, string path)
        {
            var curDir = _fileSystem.DirectoryInfo.FromDirectoryName(path);

            avInfo = null;

            /*
             * Archiveversion 1007 without base folder
             */
            if (Regex.IsMatch(curDir.Name, _folderPattern1007FirstMedia, RegexOptions.IgnoreCase))
            {
                var mainDir = _fileSystem.DirectoryInfo.FromDirectoryName(Path.Combine(curDir.FullName, "Indices"));
                if (mainDir.Exists)
                {
                    var id = curDir.Name.Substring(0, curDir.Name.Length - 2);
                    avInfo = new ArchiveVersionInfo(id, GetArciveversionMediaFolders(id, Directory.GetParent(curDir.FullName).FullName), AVRuleSet.BKG1007);
                    return(true);
                }
            }

            /*
             * Archiveversion 342 without base folder
             */
            else if (Regex.IsMatch(curDir.Name, _folderPattern342FirstMedia, RegexOptions.IgnoreCase))
            {
                var mainFile = _fileSystem.FileInfo.FromFileName(curDir.FullName + "\\arkver.tab");
                if (mainFile.Exists)
                {
                    var id = "000" + curDir.Name.Substring(0, curDir.Name.Length - 3);
                    avInfo = new ArchiveVersionInfo(id, GetArciveversionMediaFolders(id, Directory.GetParent(curDir.FullName).FullName), AVRuleSet.BKG342);
                    return(true);
                }
            }

            return(false);
        }