Exemple #1
0
        /** 写信息到文件 */
        public void write()
        {
            XML xml = new XML();

            xml.name = "infoBase";
            xml.setProperty("version", _version);

            foreach (string k in _dic.getSortedMapKeys())
            {
                FileRecordData data = _dic.get(k);

                XML xl = new XML();
                xl.name = "info";
                xl.setProperty("path", k);
                xl.setProperty("lastModified", Convert.ToString(data.lastModified));
                xl.setProperty("length", Convert.ToString(data.length));
                xl.setProperty("md5", data.md5);
                xl.setProperty("ex", data.ex);
                xl.setProperty("ex2", data.ex2);
                xl.setProperty("ex3", data.ex3);
                xl.setProperty("ex4", data.ex4);

                xml.appendChild(xl);
            }

            FileUtils.writeFileForXML(_path, xml);
        }
Exemple #2
0
        /** 获取某文件的ex4值 */
        public string getFileEx4(string path)
        {
            FileRecordData data = _dic.get(path);

            if (data == null)
            {
                return("");
            }

            return(data.ex4);
        }
Exemple #3
0
        /** 添加文件记录 */
        public void addFile(string path, string ex = "", string ex2 = "", string ex3 = "", string ex4 = "")
        {
            FileRecordData data = new FileRecordData();

            data.lastModified = File.GetLastWriteTime(path).Ticks;

            data.length = File.GetLastAccessTime(path).Ticks;

            if (_useMD5)
            {
                data.md5 = getFileMD5(path);
            }

            data.ex  = ex;
            data.ex2 = ex2;
            data.ex3 = ex3;
            data.ex4 = ex4;

            _dic.put(path, data);
        }
Exemple #4
0
        /** 加载文件记录 */
        public void read(bool allClear)
        {
            _isAllClear = allClear;

            _dic.clear();
            _lastSet.clear();

            //allClear不读
            if (File.Exists(_path) && !_isAllClear)
            {
                XML xml = FileUtils.readFileForXML(_path);

                String oldVersion = xml.getProperty("version");

                //版本对
                if (oldVersion.Equals(_version))
                {
                    foreach (XML xl in xml.getChildrenByName("info"))
                    {
                        FileRecordData data = new FileRecordData();
                        data.lastModified = Convert.ToInt64(xl.getProperty("lastModified"));
                        data.length       = Convert.ToInt64(xl.getProperty("length"));
                        data.md5          = xl.getProperty("md5");
                        data.ex           = xl.getProperty("ex");
                        data.ex2          = xl.getProperty("ex2");
                        data.ex3          = xl.getProperty("ex3");
                        data.ex4          = xl.getProperty("ex4");

                        _dic.put(xl.getProperty("path"), data);
                        _lastSet.add(xl.getProperty("path"));

                        _isNew = false;
                    }
                }
            }
        }
Exemple #5
0
        /** 是否是新文件 */
        public bool isNewFile(string path)
        {
            if (_isAllClear)
            {
                return(true);
            }

            _lastSet.remove(path);

            FileRecordData data = _dic.get(path);

            if (data == null)
            {
                return(true);
            }

            if (File.GetLastWriteTime(path).Ticks != data.lastModified)
            {
                return(true);
            }

            if (File.GetLastAccessTime(path).Ticks != data.length)
            {
                return(true);
            }

            if (_useMD5)
            {
                if (!getFileMD5(path).Equals(data.md5))
                {
                    return(true);
                }
            }

            return(false);
        }