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; }
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; } }
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)); }