/// <include file='Doc/Wrappers.xml' path='docs/method[@name="MakeDirectory"]/*'/> public override bool MakeDirectory(string path, int accessMode, StreamMakeDirectoryOptions options, StreamContext context) { if ((path == null) || (path == string.Empty)) { PhpException.Throw(PhpError.Warning, CoreResources.GetString("path_argument_empty")); return(false); } try { // Default Framework MakeDirectory is RECURSIVE, check for other intention. if ((options & StreamMakeDirectoryOptions.Recursive) == 0) { int pos = path.Length - 1; if (path[pos] == Path.DirectorySeparatorChar) { pos--; } pos = path.LastIndexOf(Path.DirectorySeparatorChar, pos); if (pos <= 0) { PhpException.Throw(PhpError.Warning, CoreResources.GetString("stream_directory_make_root", FileSystemUtils.StripPassword(path))); return(false); } // Parent must exist if not recursive. string parent = path.Substring(0, pos); if (!Directory.Exists(parent)) { PhpException.Throw(PhpError.Warning, CoreResources.GetString("stream_directory_make_parent", FileSystemUtils.StripPassword(path))); return(false); } } // Creates the whole path Directory.CreateDirectory(path); return(true); } catch (UnauthorizedAccessException) { // The caller does not have the required permission. PhpException.Throw(PhpError.Warning, CoreResources.GetString("stream_directory_access_denied", FileSystemUtils.StripPassword(path))); } catch (IOException) { // The directory specified by path is read-only or is not empty. PhpException.Throw(PhpError.Warning, CoreResources.GetString("stream_directory_error", FileSystemUtils.StripPassword(path))); } catch (Exception e) { // The specified path is invalid, such as being on an unmapped drive ... PhpException.Throw(PhpError.Warning, CoreResources.GetString("stream_error", FileSystemUtils.StripPassword(path), e.Message)); } return(false); }
/// <remarks><seealso cref="StreamMakeDirectoryOptions"/> for the list of additional options.</remarks> public virtual bool MakeDirectory(string path, int accessMode, StreamMakeDirectoryOptions options, StreamContext context) { // int (*stream_mkdir)(php_stream_wrapper *wrapper, char *url, int mode, int options, php_stream_context *context TSRMLS_DC); PhpException.Throw(PhpError.Warning, ErrResources.wrapper_op_unsupported, "Mkdir"); return(false); }
/// <remarks><seealso cref="StreamMakeDirectoryOptions"/> for the list of additional options.</remarks> public virtual bool MakeDirectory(string path, int accessMode, StreamMakeDirectoryOptions options, StreamContext context) { // int (*stream_mkdir)(php_stream_wrapper *wrapper, char *url, int mode, int options, php_stream_context *context TSRMLS_DC); PhpException.Throw(PhpError.Warning, ErrResources.wrapper_op_unsupported, "Mkdir"); return false; }
/// <include file='Doc/Wrappers.xml' path='docs/method[@name="MakeDirectory"]/*'/> public override bool MakeDirectory(string path, int accessMode, StreamMakeDirectoryOptions options, StreamContext context) { return(proxy.MakeDirectory(path, accessMode, (int)options, null)); }
public override bool MakeDirectory(string path, int accessMode, StreamMakeDirectoryOptions options, StreamContext context) { if ((path == null) || (path == string.Empty)) { PhpException.Throw(PhpError.Warning, ErrResources.path_argument_empty); return false; } try { // Default Framework MakeDirectory is RECURSIVE, check for other intention. if ((options & StreamMakeDirectoryOptions.Recursive) == 0) { int pos = path.Length - 1; if (path[pos] == Path.DirectorySeparatorChar) pos--; pos = path.LastIndexOf(Path.DirectorySeparatorChar, pos); if (pos <= 0) { PhpException.Throw(PhpError.Warning, ErrResources.stream_directory_make_root, FileSystemUtils.StripPassword(path)); return false; } // Parent must exist if not recursive. string parent = path.Substring(0, pos); if (!Directory.Exists(parent)) { PhpException.Throw(PhpError.Warning, ErrResources.stream_directory_make_parent, FileSystemUtils.StripPassword(path)); return false; } } // Creates the whole path Directory.CreateDirectory(path); return true; } catch (UnauthorizedAccessException) { // The caller does not have the required permission. PhpException.Throw(PhpError.Warning, ErrResources.stream_directory_access_denied, FileSystemUtils.StripPassword(path)); } catch (IOException) { // The directory specified by path is read-only or is not empty. PhpException.Throw(PhpError.Warning, ErrResources.stream_directory_error, FileSystemUtils.StripPassword(path)); } catch (System.Exception e) { // The specified path is invalid, such as being on an unmapped drive ... PhpException.Throw(PhpError.Warning, ErrResources.stream_error, FileSystemUtils.StripPassword(path), e.Message); } return false; }