Ejemplo n.º 1
0
        public void FindAll()
        {
            Debug.Assert(_all == null);
            _all             = new List <XMatterInfo>();
            _factoryXMatters = new List <XMatterInfo>();
            _otherXMatters   = new List <XMatterInfo>();

            bool factory = true;             // We consider the first path to be the factory ones for now.

            foreach (var path in _foldersPotentiallyHoldingPack)
            {
                if (!Directory.Exists(path))
                {
                    continue;                     // XMatter in CommonData may not exist.
                }
                foreach (var directory in Directory.GetDirectories(path, "*-XMatter", SearchOption.AllDirectories))
                {
                    AddXMatterDir(directory, factory);
                }

                foreach (var shortcut in Directory.GetFiles(path, "*.lnk", SearchOption.TopDirectoryOnly))
                {
                    var p = ResolveShortcut.Resolve(shortcut);
                    if (Directory.Exists(p))
                    {
                        AddXMatterDir(p, factory);
                    }
                }
                factory = false;
            }
        }
Ejemplo n.º 2
0
        public void FindAll()
        {
            Debug.Assert(_all == null);
            _all = new List <XMatterInfo>();

            foreach (var path in _foldersPotentiallyHoldingPack)
            {
                if (!Directory.Exists(path))
                {
                    continue;                     // XMatter in CommonData may not exist.
                }
                foreach (var directory in Directory.GetDirectories(path, "*-XMatter", SearchOption.AllDirectories))
                {
                    _all.Add(new XMatterInfo(directory));
                }

                foreach (var shortcut in Directory.GetFiles(path, "*.lnk", SearchOption.TopDirectoryOnly))
                {
                    var p = ResolveShortcut.Resolve(shortcut);
                    if (Directory.Exists(p))
                    {
                        _all.Add(new XMatterInfo(p));
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void CreateDirectoryShortcut()
        {
            using (var targetPath = new SIL.TestUtilities.TemporaryFolder(Path.GetRandomFileName()))
                using (var directory = new SIL.TestUtilities.TemporaryFolder(Path.GetRandomFileName()))
                {
                    ShortcutMaker.CreateDirectoryShortcut(targetPath.Path, directory.Path);

                    var expectedFile = Path.Combine(directory.Path, Path.GetFileName(targetPath.Path)) + ".lnk";
                    Assert.That(File.GetAttributes(expectedFile) & (FileAttributes.Directory | FileAttributes.Normal), Is.Not.Null);
                    Assert.That(ResolveShortcut.Resolve(expectedFile), Is.EqualTo(targetPath.Path));
                }
        }
        public void CreateDirectoryShortcut_FileExists()
        {
            using (var targetPath = new Palaso.TestUtilities.TemporaryFolder(Path.GetRandomFileName()))
                using (var directory = new Palaso.TestUtilities.TemporaryFolder(Path.GetRandomFileName()))
                {
                    var existingDestination = new Palaso.TestUtilities.TempFileFromFolder(directory,
                                                                                          Path.GetFileName(targetPath.Path) + ".lnk", string.Empty);

                    ShortcutMaker.CreateDirectoryShortcut(targetPath.Path, directory.Path);

                    var expectedFile = Path.Combine(directory.Path, Path.GetFileName(targetPath.Path)) + ".lnk";
                    Assert.That(File.GetAttributes(expectedFile) & (FileAttributes.Directory | FileAttributes.Normal), Is.Not.Null);
                    Assert.That(ResolveShortcut.Resolve(expectedFile), Is.EqualTo(targetPath.Path));
                }
        }