Example #1
0
        /**
         * Constructor to load dictionary with given path.
         * @param url Path of one of stardict file or Path of folder contains stardict files
         * @deprecated using StarDict.loadDict(String url)
         */
        public StarDict(string url)
        {
            if (!File.GetAttributes(url).HasFlag(FileAttributes.Directory))
            {
                m_url = Path.Combine(Path.GetDirectoryName(url), Path.GetFileNameWithoutExtension(url));
                m_ifoFile = new IfoFile(m_url + ext_info);
                m_idxFile = new IdxFile(m_url + ext_index, m_ifoFile.WordCount, m_ifoFile.IdxFileSize);
                m_dictFile = new DictFile(m_url + ext_dict);
            }
            else {
                string[] list = Directory.GetFiles(url);

                string infoPath = null;
                string indexPath = null;
                string dictPath = null;

                // Build table to mapping the file extension and file name
                for (int i = list.Length - 1; i >= 0; i--)
                {
                    if (list[i].EndsWith(ext_info))
                        infoPath = list[i];
                    else if (list[i].EndsWith(ext_index))
                        indexPath = list[i];
                    else if (list[i].EndsWith(ext_dict))
                        dictPath = list[i];
                }

                m_ifoFile = new IfoFile(Path.Combine(url, infoPath));
                m_idxFile = new IdxFile(Path.Combine(url, indexPath), m_ifoFile.WordCount, m_ifoFile.IdxFileSize);
                m_dictFile = new DictFile(Path.Combine(url, dictPath));
            }

            if (m_ifoFile.IsLoaded && m_idxFile.IsLoaded)
                m_available = true;
        }
Example #2
0
        /**
         * Constructor to load dictionary with given path.
         * @param url Path of one of stardict file or Path of folder contains stardict files
         * @deprecated using StarDict.loadDict(String url)
         */
        public StarDict(string url)
        {
            if (!File.GetAttributes(url).HasFlag(FileAttributes.Directory))
            {
                m_url      = Path.Combine(Path.GetDirectoryName(url), Path.GetFileNameWithoutExtension(url));
                m_ifoFile  = new IfoFile(m_url + ext_info);
                m_idxFile  = new IdxFile(m_url + ext_index, m_ifoFile.WordCount, m_ifoFile.IdxFileSize);
                m_dictFile = new DictFile(m_url + ext_dict);
            }
            else
            {
                string[] list = Directory.GetFiles(url);

                string infoPath  = null;
                string indexPath = null;
                string dictPath  = null;

                // Build table to mapping the file extension and file name
                for (int i = list.Length - 1; i >= 0; i--)
                {
                    if (list[i].EndsWith(ext_info))
                    {
                        infoPath = list[i];
                    }
                    else if (list[i].EndsWith(ext_index))
                    {
                        indexPath = list[i];
                    }
                    else if (list[i].EndsWith(ext_dict))
                    {
                        dictPath = list[i];
                    }
                }

                m_ifoFile  = new IfoFile(Path.Combine(url, infoPath));
                m_idxFile  = new IdxFile(Path.Combine(url, indexPath), m_ifoFile.WordCount, m_ifoFile.IdxFileSize);
                m_dictFile = new DictFile(Path.Combine(url, dictPath));
            }

            if (m_ifoFile.IsLoaded && m_idxFile.IsLoaded)
            {
                m_available = true;
            }
        }