public override sealed void UpdateParameters()
 {
     NativeSystemInfo     = new NativeFileInfo(Path);
     Icon                 = IconExtractor.GetDirectoryIcon(Path, NativeSystemInfo.IconIndex);
     _directoryInfo       = new DirectoryInfo(Path);
     LastModificationDate = _directoryInfo.LastWriteTime;
 }
示例#2
0
        private static string[] GetChildren(string path, string searchPattern, bool isDirectory)
        {
            // path and searchPattern validation in Path.GetFullPath() and Path.NormalizePath()

            path = Path.GetFullPath(path);
            Path.NormalizePath(searchPattern, true);

            ArrayList fileNames = new ArrayList();

            string root = Path.GetPathRoot(path);

            if (String.Equals(root, path))
            {
                /// This is special case. Return all the volumes.
                /// Note this will not work, once we start having \\server\share like paths.

                if (isDirectory)
                {
                    VolumeInfo[] volumes = VolumeInfo.GetVolumes();
                    int          count   = volumes.Length;
                    for (int i = 0; i < count; i++)
                    {
                        fileNames.Add(volumes[i].RootDirectory);
                    }
                }
            }
            else
            {
                Object         record = FileSystemManager.AddToOpenListForRead(path);
                NativeFindFile ff     = null;
                try
                {
                    ff = new NativeFindFile(path, searchPattern);

                    uint targetAttribute = (isDirectory ? (uint)FileAttributes.Directory : 0);

                    NativeFileInfo fileinfo = ff.GetNext();

                    while (fileinfo != null)
                    {
                        if ((fileinfo.Attributes & (uint)FileAttributes.Directory) == targetAttribute)
                        {
                            fileNames.Add(fileinfo.FileName);
                        }

                        fileinfo = ff.GetNext();
                    }
                }
                finally
                {
                    if (ff != null)
                    {
                        ff.Close();
                    }
                    FileSystemManager.RemoveFromOpenList(record);
                }
            }

            return((String[])fileNames.ToArray(typeof(String)));
        }
示例#3
0
        private void DisplayCatalogContents(object state)
        {
            Catalog cat = null;

            try
            {
                ShowWaitDialog("TXT_WAIT_LOADING_CATALOG");

                string         path = (BkgTask as Task).CatalogPath;
                NativeFileInfo nfi  = new NativeFileInfo(path, false);
                if (nfi.IsValid)
                {
                    cat = new Catalog(path);
                }
                else if (!string.IsNullOrEmpty(path))
                {
                    cat = new Catalog();
                    cat.Save(path);
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
            finally
            {
                if (cat != null && cat.IsValid)
                {
                    DisplayCatalog(cat);
                }
                CloseWaitDialog();
            }
        }
示例#4
0
 public void UpdateParameters()
 {
     _nativeFileInfo      = new NativeFileInfo(Info.FullName);
     Icon                 = _nativeFileInfo.Icon;
     Size                 = Info.Length;
     LastModificationDate = Info.LastWriteTime;
 }
示例#5
0
        public static DjvuFileInfo GetDjvuFileInfo(IntPtr nativeInfo)
        {
            NativeFileInfo infoNative = Marshal.PtrToStructure <NativeFileInfo>(nativeInfo);
            DjvuFileInfo   info       = new DjvuFileInfo(infoNative);

            return(info);
        }
        public List <SubtitleInfo> GetSubtitles(string fileName)
        {
            try
            {
                NativeFileInfo nfi = new NativeFileInfo(fileName, true);
                if (nfi.IsValid)
                {
                    if (_session == null)
                    {
                        _session = SubtitleServerSession.Create(_serverType, _serverUrl, _userName, _password);
                    }

                    if (_session != null)
                    {
                        return(_session.GetSubtitles(fileName));
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }

            return(null);
        }
示例#7
0
        public ReferenceItem(string assemblyPath, string rootpath, string assembly, string name, Version version, AssemblyAttributes attributes, string culture, byte[] publicKey, byte[] publicKeyToken)
        {
            FilterString       = DisplayName = name;
            _assembly          = assembly;
            _assemblyPath      = assemblyPath;
            _version           = version.ToString();
            _attributes        = attributes;
            _culture           = string.IsNullOrEmpty(culture) ? "Neutral" : culture;
            _publicKey         = getToken(publicKey);
            _publicKeyToken    = getToken(publicKeyToken);
            _assemblyDirectory = rootpath;
            _relativePath      = assemblyPath.Substring(rootpath.Length);
            _relativePath      = assemblyPath.Substring(rootpath.Length);
            var target = System.IO.Path.Combine(_assemblyDirectory, name + ".dll");

            if (File.Exists(target))
            {
                _targetPath = target;
                Path        = target;
                void a()
                {
                    Thumbnail = new NativeFileInfo(target).Icon;
                    Thumbnail.Freeze();
                }

                Task.Factory.StartNew(a);
                ItemType = ItemType.Container;
            }
        }
示例#8
0
 public FileViewModel(FileInfo info, IDirectoryViewModel parent)
 {
     Info            = info;
     Parent          = parent;
     Path            = VisualPath = info.FullName;
     OpenCommand     = new RelayCommand(() => Open());
     _nativeFileInfo = new NativeFileInfo(Info.FullName);
 }
示例#9
0
        private void ScanFile(Catalog cat, string file, CatalogItem parent)
        {
            if (!CanContinue())
            {
                return;
            }

            ReportPseudoStepInit("TXT_SCANNING: " + file);

            try
            {
                CatalogItem ci = new CatalogItem(cat);
                ci.IsRoot   = false;
                ci.ItemType = cat.CatalogItemType_GetByTypeCode("FIL").TypeID; // is a file
                ci.Name     = Path.GetFileName(file);

                DriveInfo di = new DriveInfo(Path.GetPathRoot(file));
                if (di.DriveType == DriveType.Removable || di.DriveType == DriveType.CDRom)
                {
                    ci.OrigItemPath = file.Replace(Path.GetPathRoot(file), "$:/");
                    if (PathUtils.DirectorySeparator != "/")
                    {
                        ci.OrigItemPath = ci.OrigItemPath.Replace(PathUtils.DirectorySeparator, "/");
                    }
                }
                else
                {
                    ci.OrigItemPath = file;
                }

                ci.RootItemLabel    = di.VolumeLabel;
                ci.RootSerialNumber = Kernel32.GetVolumeSerialNumber(di.RootDirectory.FullName);
                ci.ParentItemID     = parent.ItemID;

                try
                {
                    NativeFileInfo nfi = NativeFileInfoFactory.FromPath(file);
                    if (nfi != null)
                    {
                        ci.Description = nfi.Details;
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogException(ex);
                }

                ci.Save();

                RaiseTaskProgressEvent(null, _currentStep++);
            }
            catch (Exception ex)
            {
                ConfirmScanAbortOnException(ex);
            }

            Application.DoEvents();
        }
示例#10
0
 private DjvuFileInfo(NativeFileInfo nativeData)
 {
     Type       = nativeData.Type;
     PageNumber = nativeData.PageNumber;
     Size       = nativeData.Size;
     ID         = (string)UTF8StringMarshaler.GetInstance("").MarshalNativeToManaged(nativeData.IDPtr);
     Name       = (string)UTF8StringMarshaler.GetInstance("").MarshalNativeToManaged(nativeData.NamePtr);
     Title      = (string)UTF8StringMarshaler.GetInstance("").MarshalNativeToManaged(nativeData.TitlePtr);
 }
示例#11
0
        public List <SubtitleInfo> GetSubtitles(string fileName)
        {
            List <SubtitleInfo> retVal = new List <SubtitleInfo>();

            NativeFileInfo nfi = new NativeFileInfo(fileName, true);

            if (nfi.IsValid)
            {
                string hashCode = FileHash.ToHexadecimal(FileHash.ComputeHash(fileName));

                VideoInfo ovi = new VideoInfo();
                ovi.imdbid        = string.Empty;
                ovi.moviehash     = hashCode;
                ovi.moviebytesize = nfi.Size.GetValueOrDefault();
                ovi.sublanguageid = "all";

                #region GetSubtitles Commented code - DEBUG PURPOSE ONLY
                // Name the movie "fringe 4x03.avi"
                //ovi.moviehash = "18379ac9af039390";
                //ovi.moviebytesize = 366876694;
                #endregion

                List <SubtitleInfo> response = DoGetSubtitles(ovi);

                string[] fileNameParts = nfi.Name.ToLowerInvariant().Split(" -.][(){}".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                if (fileNameParts.Length > 0)
                {
                    List <string> fileNamePartsList = new List <string>(fileNameParts);
                    foreach (SubtitleInfo osf in response)
                    {
                        if (CheckMatch(osf.MovieName, fileNamePartsList))
                        {
                            retVal.Add(osf);
                        }
                        else if (CheckMatch(osf.MovieNameEng, fileNamePartsList))
                        {
                            retVal.Add(osf);
                        }
                        else if (CheckMatch(osf.MovieReleaseName, fileNamePartsList))
                        {
                            retVal.Add(osf);
                        }
                        else if (CheckMatch(osf.SubFileName, fileNamePartsList))
                        {
                            retVal.Add(osf);
                        }
                    }
                }
            }

            return(retVal);
        }
        private void tvImportPath_AfterSelect(object sender, TreeViewEventArgs e)
        {
            (BkgTask as Task).SourcePath = tvImportPath.SelectedNodePath;

            NativeFileInfo nfi = new NativeFileInfo((BkgTask as Task).SourcePath, false);

            Wizard.CanFinish = nfi.IsValid;

            if (Directory.Exists((BkgTask as Task).SourcePath))
            {
                string label  = string.Empty;
                string sernum = Kernel32.GetVolumeInformation(Path.GetPathRoot((BkgTask as Task).SourcePath), ref label);
                txtEntryDesc.Text = string.Format("{0}:{1}", label, sernum);
            }
        }
        public override void ShowProperties(List <string> strItems, object additionalData)
        {
            List <object> lofi = new List <object>();

            foreach (string item in strItems)
            {
                NativeFileInfo ofi = new NativeFileInfo(item, false);
                if (ofi.IsValid)
                {
                    lofi.Add(ofi);
                }
            }

            FileAttributesBrowser.ProcessObjectAttributes(lofi);

            pgProperties.SelectedObjects = lofi.ToArray();
        }
        private void DisplaySourcePath()
        {
            tvImportPath.InitOPMShellTreeView();

            if (!string.IsNullOrEmpty((BkgTask as Task).SourcePath))
            {
                NativeFileInfo nfi = new NativeFileInfo((BkgTask as Task).SourcePath, false);
                if (nfi.IsValid)
                {
                    tvImportPath.Select();
                    tvImportPath.Focus();
                    tvImportPath.DrillToFolder(nfi.Path);
                    Wizard.CanFinish = true;
                }
            }

            txtEntryDesc.Text = (BkgTask as Task).EntryDescription;
        }
示例#15
0
        public bool MoveNext()
        {
            if (m_disposed)
            {
                throw new ObjectDisposedException();
            }

            NativeFileInfo fileinfo = m_findFile.GetNext();

            while (fileinfo != null)
            {
                if (m_flags != FileEnumFlags.FilesAndDirectories)
                {
                    uint targetAttribute = (0 != (m_flags & FileEnumFlags.Directories) ? (uint)FileAttributes.Directory : 0);

                    if ((fileinfo.Attributes & (uint)FileAttributes.Directory) == targetAttribute)
                    {
                        m_currentFile = fileinfo;
                        break;
                    }
                }
                else
                {
                    m_currentFile = fileinfo;
                    break;
                }

                fileinfo = m_findFile.GetNext();
            }

            if (fileinfo == null)
            {
                m_findFile.Close();
                m_findFile = null;

                FileSystemManager.RemoveFromOpenList(m_openForReadHandle);
                m_openForReadHandle = null;
            }

            return(fileinfo != null);
        }