Example #1
0
        public void Move(string OldDirectoryFullName, string OldFileName, string NewDirectoryFullName, string NewFileName)
        {
            if (_ProtocolV2 == null)
            {
                throw new NFSConnectionException("NFS Client not connected!");
            }

            if (_MountProtocolV2 == null)
            {
                throw new NFSMountConnectionException("NFS Device not connected!");
            }

            NFSAttributes OldDirectory = GetItemAttributes(OldDirectoryFullName);
            NFSAttributes NewDirectory = GetItemAttributes(NewDirectoryFullName);

            RenameArguments dpArgRename = new RenameArguments();

            dpArgRename.From           = new ItemOperationArguments();
            dpArgRename.From.Directory = new NFSHandle(OldDirectory.Handle, V2.RPC.NFSv2Protocol.NFS_VERSION);
            dpArgRename.From.Name      = new Name(OldFileName);
            dpArgRename.To             = new ItemOperationArguments();
            dpArgRename.To.Directory   = new NFSHandle(NewDirectory.Handle, V2.RPC.NFSv2Protocol.NFS_VERSION);
            dpArgRename.To.Name        = new Name(NewFileName);

            NFSStats Status =
                (NFSStats)_ProtocolV2.NFSPROC_RENAME(dpArgRename);

            if (Status != NFSStats.NFS_OK)
            {
                ExceptionHelpers.ThrowException(Status);
            }
        }
Example #2
0
        public void DeleteFile(string FileFullName)
        {
            if (_ProtocolV2 == null)
            {
                throw new NFSConnectionException("NFS Client not connected!");
            }

            if (_MountProtocolV2 == null)
            {
                throw new NFSMountConnectionException("NFS Device not connected!");
            }

            string ParentDirectory = System.IO.Path.GetDirectoryName(FileFullName);
            string FileName        = System.IO.Path.GetFileName(FileFullName);

            NFSAttributes ParentItemAttributes = GetItemAttributes(ParentDirectory);

            ItemOperationArguments dpArgDelete = new ItemOperationArguments();

            dpArgDelete.Directory = new NFSHandle(ParentItemAttributes.Handle, V2.RPC.NFSv2Protocol.NFS_VERSION);
            dpArgDelete.Name      = new Name(FileName);

            NFSStats Status = (NFSStats)_ProtocolV2.NFSPROC_REMOVE(dpArgDelete);

            if (Status != NFSStats.NFS_OK)
            {
                ExceptionHelpers.ThrowException(Status);
            }
        }
Example #3
0
 public void xdrDecode(XdrDecodingStream xdr)
 {
     this._status = (NFSStats)xdr.xdrDecodeInt();
     switch (this._status)
     {
         case NFSStats.NFS_OK:
             this._ok = new ReadAccessOK(xdr);
             break;
         default:
             break;
     }
 }
Example #4
0
        public void xdrDecode(XdrDecodingStream xdr)
        {
            this._status = (NFSStats)xdr.xdrDecodeInt();
            switch (this._status)
            {
            case NFSStats.NFS_OK:
                this._ok = new ReadAccessOK(xdr);
                break;

            default:
                break;
            }
        }
Example #5
0
        public void xdrDecode(XdrDecodingStream xdr)
        {
            this._status = (NFSStats)xdr.xdrDecodeInt();

            switch (this._status)
            {
                case NFSStats.NFS_OK:
                    this._linkname = new Name(xdr);
                    break;
                default:
                    break;
            }
        }
Example #6
0
        public void xdrDecode(XdrDecodingStream xdr)
        {
            this._status = (NFSStats)xdr.xdrDecodeInt();

            switch (this._status)
            {
                case NFSStats.NFS_OK:
                    this._attributes = new FileAttributes(xdr);
                    break;
                default:
                    break;
            }
        }
Example #7
0
        public void xdrDecode(XdrDecodingStream xdr)
        {
            this._status = (NFSStats)xdr.xdrDecodeInt();

            switch (this._status)
            {
            case NFSStats.NFS_OK:
                this._linkname = new Name(xdr);
                break;

            default:
                break;
            }
        }
Example #8
0
        public void xdrDecode(XdrDecodingStream xdr)
        {
            this._status = (NFSStats)xdr.xdrDecodeInt();

            switch (this._status)
            {
            case NFSStats.NFS_OK:
                this._attributes = new FileAttributes(xdr);
                break;

            default:
                break;
            }
        }
Example #9
0
        public void xdrDecode(XdrDecodingStream xdr)
        {
            this._status = (NFSStats)xdr.xdrDecodeInt();

            switch (this._status)
            {
            case NFSStats.NFS_OK:
                Type OK = typeof(O);

                this._resok = (O)Activator.CreateInstance(OK, new object[] { xdr });
                break;

            default:
                Type FAIL = typeof(F);

                this._resfail = (F)Activator.CreateInstance(FAIL, new object[] { xdr });
                break;
            }
        }
Example #10
0
        public static void ThrowException(NFSStats ErrorCode)
        {
            if (ErrorCode != NFSStats.NFS_OK)
            {
                System.Collections.Generic.Dictionary <NFSStats, String> exceptionMessages =
                    ExceptionHelpers.ExceptionList();

                if (exceptionMessages.ContainsKey(ErrorCode))
                {
                    String Message = exceptionMessages[ErrorCode];

                    switch (ErrorCode)
                    {
                    case NFSStats.NFSERR_ACCES:
                        throw new NFSAuthenticationException(Message);

                    case NFSStats.NFSERR_DQUOT:
                    case NFSStats.NFSERR_EXIST:
                    case NFSStats.NFSERR_FBIG:
                    case NFSStats.NFSERR_IO:
                    case NFSStats.NFSERR_ISDIR:
                    case NFSStats.NFSERR_NAMETOOLONG:
                    case NFSStats.NFSERR_NOENT:
                    case NFSStats.NFSERR_NOSPC:
                    case NFSStats.NFSERR_NOTDIR:
                    case NFSStats.NFSERR_NOTEMPTY:
                    case NFSStats.NFSERR_NXIO:
                        throw new NFSIOException(Message);

                    case NFSStats.NFSERR_PERM:
                    case NFSStats.NFSERR_ROFS:
                        throw new NFSUnauthorizedAccessException(Message);

                    case NFSStats.NFSERR_BADHANDLE:
                    case NFSStats.NFSERR_BADTYPE:
                    case NFSStats.NFSERR_TOOSMALL:
                    case NFSStats.NFSERR_SERVERFAULT:
                    case NFSStats.NFSERR_JUKEBOX:
                        throw new NFSCommunicationException(Message);

                    case NFSStats.NFSERR_XDEV:
                    case NFSStats.NFSERR_REMOTE:
                    case NFSStats.NFSERR_NOTSUPP:
                    case NFSStats.NFSERR_NOT_SYNC:
                    case NFSStats.NFSERR_NODEV:
                    case NFSStats.NFSERR_MLINK:
                    case NFSStats.NFSERR_INVAL:
                    case NFSStats.NFSERR_BAD_COOKIE:
                    case NFSStats.NFSERR_STALE:
                    case NFSStats.NFSERR_WFLUSH:
                        throw new NFSGeneralException(Message);

                    default:
                        throw new NFSGeneralException("General Exception Occured!");
                    }
                }
                else
                {
                    throw new NFSGeneralException("Unknown Exception Occured!");
                }
            }
        }
Example #11
0
        public static void ThrowException(NFSStats ErrorCode)
        {
            if (ErrorCode != NFSStats.NFS_OK)
            {
                System.Collections.Generic.Dictionary<NFSStats, String> exceptionMessages =
                    ExceptionHelpers.ExceptionList();

                if (exceptionMessages.ContainsKey(ErrorCode))
                {
                    String Message = exceptionMessages[ErrorCode];

                    switch (ErrorCode)
                    {
                        case NFSStats.NFSERR_ACCES:
                            throw new NFSAuthenticationException(Message);                      
                        
                        case NFSStats.NFSERR_DQUOT:
                        case NFSStats.NFSERR_EXIST:
                        case NFSStats.NFSERR_FBIG:
                        case NFSStats.NFSERR_IO:
                        case NFSStats.NFSERR_ISDIR:
                        case NFSStats.NFSERR_NAMETOOLONG:
                        case NFSStats.NFSERR_NOENT:
                        case NFSStats.NFSERR_NOSPC:
                        case NFSStats.NFSERR_NOTDIR:
                        case NFSStats.NFSERR_NOTEMPTY:
                        case NFSStats.NFSERR_NXIO:
                            throw new NFSIOException(Message);

                        case NFSStats.NFSERR_PERM:
                        case NFSStats.NFSERR_ROFS:
                            throw new NFSUnauthorizedAccessException(Message);

                        case NFSStats.NFSERR_BADHANDLE:
                        case NFSStats.NFSERR_BADTYPE:
                        case NFSStats.NFSERR_TOOSMALL:
                        case NFSStats.NFSERR_SERVERFAULT:
                        case NFSStats.NFSERR_JUKEBOX:
                            throw new NFSCommunicationException(Message);

                        case NFSStats.NFSERR_XDEV:
                        case NFSStats.NFSERR_REMOTE:
                        case NFSStats.NFSERR_NOTSUPP:
                        case NFSStats.NFSERR_NOT_SYNC:
                        case NFSStats.NFSERR_NODEV:
                        case NFSStats.NFSERR_MLINK:
                        case NFSStats.NFSERR_INVAL:
                        case NFSStats.NFSERR_BAD_COOKIE:
                        case NFSStats.NFSERR_STALE:
                        case NFSStats.NFSERR_WFLUSH:
                            throw new NFSGeneralException(Message);

                        default:
                            throw new NFSGeneralException("General Exception Occured!");

                    }
                }
                else
                { throw new NFSGeneralException("Unknown Exception Occured!"); }
            }
        }