示例#1
0
        public RootShareDirectory(String localShareDirectory, String shareName)
        {
            if (!PlatformPath.IsValidUnixFileName(shareName))
            {
                throw new ArgumentException(String.Format("The share name you provided '{0}' is not valid (cannot have '/')", shareName));
            }

            this.directoryInfo = new DirectoryInfo(localShareDirectory);
            this.driveInfo     = new DriveInfo(directoryInfo.Root.FullName);

            this.localShareDirectory = localShareDirectory;
            this.shareName           = shareName;
        }
示例#2
0
 void SetShareLeafName(String shareLeafName)
 {
     if (PlatformPath.IsValidUnixFileName(shareLeafName))
     {
         this.shareLeafName = shareLeafName;
     }
     else
     {
         String newShareLeafName = NfsPath.LeafName(shareLeafName);
         if (!PlatformPath.IsValidUnixFileName(newShareLeafName))
         {
             throw new InvalidOperationException(String.Format("The file you supplied '{0}' is not a valid unix file name", shareLeafName));
         }
         this.shareLeafName = newShareLeafName;
     }
 }
示例#3
0
        public ShareObject TryGetSharedObject(FileType expectedFileType, String localParentDirectory, String localPathAndName)
        {
            switch (expectedFileType)
            {
            case FileType.Regular:
                if (!File.Exists(localPathAndName))
                {
                    return(null);
                }
                break;

            case FileType.Directory:
                if (!Directory.Exists(localPathAndName))
                {
                    return(null);
                }
                break;

            default:
                return(null);
            }

            ShareObject shareObject;

            if (shareObjectsByLocalPath.TryGetValue(localPathAndName, out shareObject))
            {
                if (shareObject.fileType == expectedFileType)
                {
                    return(shareObject);
                }
                DisposeShareObject(shareObject);
            }

            String shareName = PlatformPath.LocalPathDiff(localParentDirectory, localPathAndName);

            if (!PlatformPath.IsValidUnixFileName(shareName))
            {
                throw new InvalidOperationException(String.Format("The file you supplied '{0}' is not a valid unix file name", shareName));
            }

            return(CreateNewShareObject(expectedFileType, localPathAndName, shareName));
        }