예제 #1
0
        public Fileinfo get_info_raw(string path)
        {
            string   str = this.apply_profile(path);
            Fileinfo fileinfo1;

            try
            {
                FileInfo fileInfo = new FileInfo(str);
                fileinfo1 = new Fileinfo(path, fileInfo.Length, fileInfo.CreationTime, fileInfo.LastWriteTime, (fileInfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory);
            }
            catch (Exception ex)
            {
                Fileinfo fileinfo2;
                try
                {
                    DirectoryInfo directoryInfo = new DirectoryInfo(str);
                    if (directoryInfo == null || !directoryInfo.Exists)
                    {
                        return((Fileinfo)null);
                    }
                    fileinfo2 = new Fileinfo(path, 0L, directoryInfo.CreationTime, directoryInfo.LastWriteTime, true);
                }
                catch
                {
                    clib.imsg("get_info: failed {0} {1}", (object)str, (object)ex.Message);
                    return((Fileinfo)null);
                }
                return(fileinfo2);
            }
            return(fileinfo1);
        }
예제 #2
0
        public void get_index_deeper(Index addto, string path)
        {
            Index index = this.get_index(path);

            if (path == null)
            {
                return;
            }
            if (!this.is_dir(path))
            {
                Fileinfo info = this.get_info(path);
                if (info == null)
                {
                    return;
                }
                addto.add(info);
            }
            else
            {
                foreach (Fileinfo f in index)
                {
                    addto.add(f);
                    if (f.isdir)
                    {
                        this.get_index_deeper(addto, f.name);
                    }
                }
            }
        }
예제 #3
0
 private string fact_get(Fileinfo f)
 {
     if (f == null)
     {
         return(string.Format("null fileinfo"));
     }
     return(f.isdir ? string.Format("type=dir;size={0}; {1}", (object)f.size, (object)clib.string_to_utf8(f.name.file_only())) : string.Format("type=file;size={0};modify={1}; {2}", (object)f.size, (object)clib.date_to_ftp(f.modified), (object)clib.string_to_utf8(f.name.file_only())));
 }
예제 #4
0
 public void add(Fileinfo f)
 {
     if (f == null)
     {
         return;
     }
     clib.imsg("Files: index_add {0}", (object)f.name);
     f.name = Files.fname_decode(f.name);
     f.name = Files.tild_decode(f.name);
     clib.imsg("Files: index_add_decoded {0}", (object)f.name);
     this.all.Add(f);
 }
예제 #5
0
        private void cmd_size(string cmd, string p1)
        {
            Fileinfo info = this.files.get_info(this.apply_path(p1));

            if (info == null)
            {
                this.send("550 could not get file size informatin \r\n");
            }
            else
            {
                this.send("213 {0}\r\n", (object)info.size);
            }
        }
예제 #6
0
        public Index get_tree(string path, bool deeper)
        {
            Index    addto = new Index();
            Fileinfo info  = this.get_info(path);

            if (info == null)
            {
                return(addto);
            }
            if (!deeper)
            {
                addto.add(info);
                return(addto);
            }
            clib.imsg("get_tree, adding dir and contents");
            addto.add(info);
            if (info.isdir)
            {
                this.get_index_deeper(addto, path);
            }
            return(addto);
        }
예제 #7
0
        public bool property_load(string path)
        {
            path = this.tild_encode(path);
            string path1 = this.apply_profile(path);

            this.prop = new Property();
            this.prop.load(path1);
            Fileinfo infoRaw = this.get_info_raw(path);

            clib.imsg("Property load {0} {1} ", (object)path1, (object)File.Exists(path1));
            this.prop.set("DAV::supportedlock", "<D:lockentry><D:lockscope><D:exclusive/></D:lockscope><D:locktype><D:write/></D:locktype><D:lockscope><D:shared/></D:lockscope><D:locktype><D:write/></D:locktype></D:lockentry>");
            this.load_lock(path);
            if (infoRaw == null)
            {
                return(false);
            }
            if (infoRaw != null)
            {
                this.prop.set("DAV::getcontentlength", clib.long_to_string(infoRaw.size));
                this.prop.set("DAV::creationdate", infoRaw.created.ToString("s") + "-00:00");
                this.prop.set("DAV::getlastmodified", infoRaw.modified.ToHttpDate());
                this.prop.set("DAV::getcontenttype", clib.content_type(infoRaw.name));
                this.prop.set("DAV::displayname", clib.xml_encode(clib.fileonly(infoRaw.name)));
                this.prop.set("DAV::getetag", infoRaw.etag());
                if (infoRaw.isdir)
                {
                    this.prop.set("DAV::resourcetype", "<D:collection/>");
                }
                if (infoRaw.isdir)
                {
                    if (this.quota_permitted > 0L)
                    {
                        this.prop.set("DAV::quota-available-bytes", clib.long_to_string(this.quota_permitted));
                    }
                    this.prop.set("DAV::quota-used-bytes", clib.long_to_string(Quota.get(this.current_user)));
                }
            }
            return(true);
        }
예제 #8
0
        public Index get_index(string path)
        {
            Index  index         = new Index();
            string searchPattern = (string)null;

            path = this.tild_encode(path);
            string str = this.apply_profile(path);

            if (str.EndsWith("\\"))
            {
                str = str.Substring(0, str.Length - 1);
            }
            else
            {
                try
                {
                    if (!Directory.Exists(str))
                    {
                        if (File.Exists(str))
                        {
                            FileInfo ff = new FileInfo(str);
                            index.add(new Fileinfo(path, ff));
                            return(index);
                        }
                    }
                    else
                    {
                        goto label_7;
                    }
                }
                catch
                {
                }
                searchPattern = clib.fileonly(str);
                str           = clib.pathonly(str);
                path          = clib.pathonly(path);
            }
label_7:
            FileInfo[]      files;
            DirectoryInfo[] directories;
            try
            {
                DirectoryInfo directoryInfo = new DirectoryInfo(str);
                if (searchPattern == null)
                {
                    files       = directoryInfo.GetFiles();
                    directories = directoryInfo.GetDirectories();
                }
                else
                {
                    files       = directoryInfo.GetFiles(searchPattern);
                    directories = directoryInfo.GetDirectories(searchPattern);
                }
            }
            catch (Exception ex)
            {
                clib.imsg("Caught error {0}", (object)ex.Message);
                return(index);
            }
            if (path == "/")
            {
                foreach (VPath path1 in this.profile.paths)
                {
                    if (!(path1.alias == "/"))
                    {
                        Fileinfo f = new Fileinfo(path1.alias, 0L, DateTime.Now, DateTime.Now, true);
                        index.add(f);
                    }
                }
            }
            foreach (DirectoryInfo directoryInfo in directories)
            {
                if (clib.path_valid(directoryInfo.Name))
                {
                    index.add(new Fileinfo(this.fixname(str, directoryInfo.Name, path), 0L, directoryInfo.CreationTime, directoryInfo.LastWriteTime, true));
                }
            }
            foreach (FileInfo ff in files)
            {
                if (!ff.Name.EndsWith(Files.pext) && !ff.Name.Contains(".~") && clib.path_valid(ff.Name))
                {
                    string name = this.fixname(str, ff.Name, path);
                    clib.imsg("Index: file name is {0}  ", (object)name);
                    index.add(new Fileinfo(name, ff));
                }
            }
            return(index);
        }
예제 #9
0
        public string get_etag(string path)
        {
            Fileinfo info = this.get_info(path);

            return(info == null ? "noetagyet" : info.etag());
        }
예제 #10
0
        public bool is_dir_raw(string fname)
        {
            Fileinfo infoRaw = this.get_info_raw(fname);

            return(infoRaw != null && infoRaw.isdir);
        }