Ejemplo n.º 1
0
        public static string GetCanonicalSymLinkTarget(string symLinkPath)
        {
#if WIN32
            throw new NotImplementedException();
#else
            return(UnixFileHelper.ReadLink(symLinkPath, true));
#endif
        }
Ejemplo n.º 2
0
        public static FileType GetFileType(string path, bool followSymLinks)
        {
#if WIN32
            // TODO : test me, is it working?
            System.IO.FileAttributes attr = System.IO.File.GetAttributes(path);
            return((attr & System.IO.FileAttributes.Directory) != 0 ? FileType.Directory : FileType.RegularFile);
#else
            Mono.Unix.Native.Stat stat;
            if (followSymLinks)
            {
                stat = UnixFileHelper.GetStat(path);
            }
            else
            {
                stat = UnixFileHelper.GetLStat(path);
            }

            FileType     ft;
            UnixFileType uft = UnixFileHelper.GetFileType(stat);
            switch (uft)
            {
            case UnixFileType.Directory:
                ft = FileType.Directory;
                break;

            case UnixFileType.CharacterDevice:
                ft = FileType.CharacterDevice;
                break;

            case UnixFileType.BlockDevice:
                ft = FileType.BlockDevice;
                break;

            case UnixFileType.RegularFile:
                ft = FileType.RegularFile;
                break;

            case UnixFileType.Fifo:
                ft = FileType.Fifo;
                break;

            case UnixFileType.SymbolicLink:
                ft = FileType.SymbolicLink;
                break;

            case UnixFileType.Socket:
                ft = FileType.Socket;
                break;

            default:
                throw new NotImplementedException(string.Format("UnixFileType {0} has no equivalent FileType value yet", uft.ToString()));
            }
            return(ft);
#endif
        }