예제 #1
0
 public UnixFileSystemInfo GetContents()
 {
     ReadLink();
     return(UnixFileSystemInfo.GetFileSystemEntry(
                UnixPath.Combine(UnixPath.GetDirectoryName(FullPath),
                                 ContentsPath)));
 }
예제 #2
0
        public static bool TryGetFileSystemEntry(string path, out UnixFileSystemInfo entry)
        {
            Native.Stat stat;
            int         r = Native.Syscall.lstat(path, out stat);

            if (r == -1)
            {
                if (Native.Stdlib.GetLastError() == Native.Errno.ENOENT)
                {
                    entry = new UnixFileInfo(path);
                    return(true);
                }
                entry = null;
                return(false);
            }

            if (IsFileType(stat.st_mode, Native.FilePermissions.S_IFDIR))
            {
                entry = new UnixDirectoryInfo(path, stat);
            }
            else if (IsFileType(stat.st_mode, Native.FilePermissions.S_IFLNK))
            {
                entry = new UnixSymbolicLinkInfo(path, stat);
            }
            else
            {
                entry = new UnixFileInfo(path, stat);
            }

            return(true);
        }
 private UnixFileSystemInfo[] GetFileSystemEntries(Dirent[] dentries)
 {
     UnixFileSystemInfo[] fileSystemEntry = new UnixFileSystemInfo[(int)dentries.Length];
     for (int i = 0; i != (int)fileSystemEntry.Length; i++)
     {
         fileSystemEntry[i] = UnixFileSystemInfo.GetFileSystemEntry(UnixPath.Combine(base.FullPath, new string[] { dentries[i].d_name }));
     }
     return(fileSystemEntry);
 }
 private UnixFileSystemInfo[] GetFileSystemEntries(Native.Dirent[] dentries)
 {
     UnixFileSystemInfo[] entries = new UnixFileSystemInfo[dentries.Length];
     for (int i = 0; i != entries.Length; ++i)
     {
         entries [i] = UnixFileSystemInfo.GetFileSystemEntry(
             UnixPath.Combine(FullPath, dentries[i].d_name));
     }
     return(entries);
 }
예제 #5
0
        public static UnixFileSystemInfo GetFileSystemEntry(string path)
        {
            Stat stat;
            int  num = Syscall.lstat(path, out stat);

            if (num == -1 && Stdlib.GetLastError() == Errno.ENOENT)
            {
                return(new UnixFileInfo(path));
            }
            UnixMarshal.ThrowExceptionForLastErrorIf(num);
            if (UnixFileSystemInfo.IsFileType(stat.st_mode, FilePermissions.S_IFDIR))
            {
                return(new UnixDirectoryInfo(path, stat));
            }
            if (UnixFileSystemInfo.IsFileType(stat.st_mode, FilePermissions.S_IFLNK))
            {
                return(new UnixSymbolicLinkInfo(path, stat));
            }
            return(new UnixFileInfo(path, stat));
        }
 public void Delete(bool recursive)
 {
     if (recursive)
     {
         UnixFileSystemInfo[] fileSystemEntries = this.GetFileSystemEntries();
         for (int i = 0; i < (int)fileSystemEntries.Length; i++)
         {
             UnixFileSystemInfo unixFileSystemInfo = fileSystemEntries[i];
             UnixDirectoryInfo  unixDirectoryInfo  = unixFileSystemInfo as UnixDirectoryInfo;
             if (unixDirectoryInfo == null)
             {
                 unixFileSystemInfo.Delete();
             }
             else
             {
                 unixDirectoryInfo.Delete(true);
             }
         }
     }
     UnixMarshal.ThrowExceptionForLastErrorIf(Syscall.rmdir(base.FullPath));
     base.Refresh();
 }
예제 #7
0
파일: helpers.cs 프로젝트: kig/filezoo
 /** BLOCKING */
 public static string OwnerName(UnixFileSystemInfo f)
 {
     try {
       long uid = f.ToStat().st_uid;
       if (OwnerNameCache.ContainsKey(uid)) {
     return OwnerNameCache[uid];
       } else {
     try {
       UnixUserInfo uf = f.OwnerUser;
       return OwnerNameCache[uf.UserId] = uf.UserName;
     } catch (System.ArgumentException) {
       return OwnerNameCache[uid] = uid.ToString();
     }
       }
     }
     catch (System.InvalidOperationException) { return ""; }
 }
예제 #8
0
 public UnixFileSystemInfo CreateLink(string path)
 {
     UnixMarshal.ThrowExceptionForLastErrorIf(Syscall.link(this.FullName, path));
     return(UnixFileSystemInfo.GetFileSystemEntry(path));
 }
예제 #9
0
파일: helpers.cs 프로젝트: kig/filezoo
 /** BLOCKING */
 public static bool IsDir(UnixFileSystemInfo f)
 {
     try { return f.IsDirectory; }
     catch (System.InvalidOperationException) { return false; }
 }
예제 #10
0
파일: helpers.cs 프로젝트: kig/filezoo
 /** BLOCKING */
 public static DateTime LastModified(UnixFileSystemInfo f)
 {
     try {
       return f.LastWriteTime;
     } catch (Exception) {
       return DefaultTime;
     }
 }
예제 #11
0
파일: helpers.cs 프로젝트: kig/filezoo
 /** BLOCKING */
 public static FileTypes FileType(UnixFileSystemInfo f)
 {
     try {
       return (new UnixSymbolicLinkInfo(f.FullName)).FileType;
     }
     catch (System.InvalidOperationException) { return FileTypes.RegularFile; }
 }
예제 #12
0
파일: helpers.cs 프로젝트: kig/filezoo
 /** BLOCKING */
 public static string GroupName(UnixFileSystemInfo f)
 {
     try {
       long gid = f.ToStat().st_gid;
       if (GroupNameCache.ContainsKey(gid)) {
     return GroupNameCache[gid];
       } else {
     try {
       UnixGroupInfo uf = f.OwnerGroup;
       return GroupNameCache[uf.GroupId] = uf.GroupName;
     } catch (System.ArgumentException) {
       return GroupNameCache[gid] = gid.ToString();
     }
       }
     }
     catch (System.InvalidOperationException) { return ""; }
 }
예제 #13
0
파일: helpers.cs 프로젝트: kig/filezoo
 /** BLOCKING */
 public static FileAccessPermissions FilePermissions(UnixFileSystemInfo f)
 {
     try { return f.FileAccessPermissions; }
     catch (System.InvalidOperationException) { return (FileAccessPermissions)0; }
 }
예제 #14
0
파일: fsentry.cs 프로젝트: kig/filezoo
    public void Setup(UnixFileSystemInfo u)
    {
        FullName = u.FullName;
        Name = u.Name;
        LCName = Name.ToLower ();

        Owner = Helpers.OwnerName(u);
        Group = Helpers.GroupName(u);

        LastModified = Helpers.LastModified(u);
        LastFileChange = Helpers.LastChange(FullName);
        Permissions = Helpers.FilePermissions(u);
        FileType = Helpers.FileType(u);

        IsDirectory = FileType == FileTypes.Directory;
        if (FileType == FileTypes.SymbolicLink) {
          LinkTarget = Helpers.ReadLink(FullName);
          var lt = new UnixSymbolicLinkInfo(LinkTarget);
          IsDirectory = Helpers.FileExists(LinkTarget) && Helpers.FileType(lt) == FileTypes.Directory;
        }

        Suffix = IsDirectory ? "" : Helpers.Extname(Name).ToLower();

        Size = Helpers.FileSize(u);

        if (!IsDirectory) {
          Count = 1;
          SubTreeSize = Size;
          SubTreeCount = 1;
          Complete = true;
          FilePassDone = true;
        } else {
          Count = 0;
          Entries = new List<FSEntry> ();
        }
    }
예제 #15
0
        public void CreateSymbolicLinkTo(UnixFileSystemInfo path)
        {
            int r = Native.Syscall.symlink(path.FullName, FullName);

            UnixMarshal.ThrowExceptionForLastErrorIf(r);
        }
        public void CreateSymbolicLinkTo(UnixFileSystemInfo path)
        {
            int num = Syscall.symlink(path.FullName, this.FullName);

            UnixMarshal.ThrowExceptionForLastErrorIf(num);
        }
예제 #17
0
		public static bool TryGetFileSystemEntry (string path, out UnixFileSystemInfo entry)
		{
			Native.Stat stat;
			int r = Native.Syscall.lstat (path, out stat);
			if (r == -1) {
				if (Native.Stdlib.GetLastError() == Native.Errno.ENOENT) {
					entry = new UnixFileInfo (path);
					return true;
				}
				entry = null;
				return false;
			}

			if (IsFileType (stat.st_mode, Native.FilePermissions.S_IFDIR))
				entry = new UnixDirectoryInfo (path, stat);
			else if (IsFileType (stat.st_mode, Native.FilePermissions.S_IFLNK))
				entry = new UnixSymbolicLinkInfo (path, stat);
			else
				entry = new UnixFileInfo (path, stat);

			return true;
		}
예제 #18
0
		private void GetUnixInfo(string fullName)
		{
			UnixDirectoryInfo = UnixFileSystemInfo.GetFileSystemEntry(fullName);
		}
예제 #19
0
		private UnixFileSystemInfo[] GetFileSystemEntries (Native.Dirent[] dentries)
		{
			UnixFileSystemInfo[] entries = new UnixFileSystemInfo[dentries.Length];
			for (int i = 0; i != entries.Length; ++i)
				entries [i] = UnixFileSystemInfo.GetFileSystemEntry (
						UnixPath.Combine (FullPath, dentries[i].d_name));
			return entries;
		}
 public UnixFileSystemInfo GetContents()
 {
     this.ReadLink();
     return(UnixFileSystemInfo.GetFileSystemEntry(UnixPath.Combine(UnixPath.GetDirectoryName(base.FullPath), new string[] { this.ContentsPath })));
 }
예제 #21
0
파일: helpers.cs 프로젝트: kig/filezoo
 public static long FileSize(UnixFileSystemInfo f)
 {
     try { return f.Length; }
     catch (System.InvalidOperationException) { return 0; }
 }
예제 #22
0
파일: Directory.cs 프로젝트: knocte/banshee
        private UnixFileSystemInfo TraverseSymlink(UnixFileSystemInfo info)
        {
            lock (visited_symlinks) {
                visited_symlinks.Clear ();
                while (info.IsSymbolicLink) {
                    if (visited_symlinks.Contains (info.FullName)) {
                        return null;
                    }
                    visited_symlinks.Add (info.FullName);
                    var target = new UnixSymbolicLinkInfo (info.FullName).GetContents ();
                    if (info.FullName.StartsWith (target.FullName)) {
                        return null;
                    }
                    if (!target.Exists) {
                        return null;
                    }
                    info = target;
                }

                return info;
            }
        }
예제 #23
0
파일: fsentry.cs 프로젝트: kig/filezoo
 public FSEntry(UnixFileSystemInfo u)
 {
     LastDraw = FSDraw.frame;
     Setup(u);
 }
		public void CreateSymbolicLinkTo (UnixFileSystemInfo path)
		{
			int r = Syscall.symlink (path.FullName, OriginalPath);
			UnixMarshal.ThrowExceptionForLastErrorIf (r);
		}
		private UnixFileSystemInfo[] GetFileSystemEntries (Dirent[] dentries)
		{
			UnixFileSystemInfo[] entries = new UnixFileSystemInfo[dentries.Length];
			for (int i = 0; i != entries.Length; ++i)
				entries [i] = UnixFileSystemInfo.Create (dentries[i].d_name);
			return entries;
		}