Пример #1
0
        public override NT_STATUS Rename(UserContext UserContext, string OldName, string NewName)
        {
            NT_STATUS error = NT_STATUS.OK;

            if (phone.Exists(root + OldName) && phone.IsDirectory(root + OldName))
            {
                // We are in Directory case
                if (phone.Exists(root + NewName))
                {
                    return(NT_STATUS.OBJECT_NAME_COLLISION);
                }
                try
                {
                    //FIXME: We don't have a way to move directories
                    //DirectoryBroker.Move(phone,root + OldName, root + NewName);
                    phone.Rename(root + OldName, root + NewName);
                    return(NT_STATUS.OBJECT_NAME_COLLISION);
                }
                catch (Exception e)
                {
                    Trace.WriteLine("Warning->Exception when renaming directory: " + e.Message);
                    error = (NT_STATUS)Marshal.GetHRForException(e);
                    //error = 3;					// ListingError
                }
            }
            else
            {   // We are in File case
                if (!phone.Exists(root + OldName))
                {
                    return(NT_STATUS.OBJECT_NAME_NOT_FOUND);             // Orginalname nicht da
                }
                if (phone.Exists(root + NewName))
                {
                    return(NT_STATUS.OBJECT_NAME_COLLISION);
                }
                try
                {
                    phone.Rename(root + OldName, root + NewName);
                }
                catch (Exception e)
                {
                    Trace.WriteLine("Warning->Exception when renaming file: " + e.Message);
                    error = (NT_STATUS)Marshal.GetHRForException(e);
                }
            }
            return(error);
        }