mkdir

Does Ruby have mkdir -p? [duplicate]

笑着哭i 提交于 2019-12-02 17:13:54
Possible Duplicate: How to create directories recursively in ruby? In Ruby, how could I do: mkdir -p cool/beans Here's what I came up with: Dir.mkdir('cool') unless File.directory?('cool') cool_beans_path = File.join('cool', 'beans') Dir.mkdir(cool_beans_path) unless File.directory?(cool_beans_path) But, isn't there a better way? I know I could do: system('mkdir', '-p', File.join('cool', 'beans')) But, that's not platform independent, is it? Like, it works on Mac but not on Windows, right? require 'fileutils' FileUtils.mkdir_p 'cool/beans' 来源: https://stackoverflow.com/questions/11463343/does

How to create nested directories using Mkdir in Golang?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 16:27:55
I am trying to create a set of nested directories from a Go executable such as 'dir1/dir2/dir3'. I have succeeded in creating a single directory with this line: os.Mkdir("." + string(filepath.Separator) + c.Args().First(),0777); However, I have no idea how to approach creating a predetermined nested set of directories inside of that directory. ANisus os.Mkdir is used to create a single directory. To create a folder path, instead try using: os.MkdirAll(folderPath, os.ModePerm) Go documentation func MkdirAll(path string, perm FileMode) error MkdirAll creates a directory named path, along with

How to make directory within directory by php loop?

眉间皱痕 提交于 2019-12-02 13:36:27
How to make directory within directory by php loop? Example: http://site_name/a/b/c/d First create a then b within a then c within b then .... Problem is here a,b,c,d all the folders created in root directory not one within one. Here is my code - <?php $url = "http://site_name/a/b/c/d"; $details1 = parse_url(dirname($url)); $base_url = $details1['scheme'] . "//" . $details1['host'] . "/"; if ($details1['host'] == 'localhost') { $path_init = 2; }else { $path_init = 1; } $paths = explode("/", $details1['path']); for ($i = $path_init; $i < count($paths); $i++) { $new_dir = ''; $base_url = $base

mkdir always sets folders to read-only?

可紊 提交于 2019-12-02 10:41:42
i am trying to create folders from within php. Whenever i use the mkdir function with permission 0777 i get a read-only folder. I want this folder to be read & write. The parent folder ( drive/ ) is fully writable and readable for every user. This is what i use: mkdir(ABSPATH . 'drive/' . $folderName, 0777); I have also tried to use it without any additional paramaters: mkdir(ABSPATH . 'drive/' . $folderName); Any ideas why this is and how to fix this so that i can generate folders that has write access? In a shared environment, mkdir fails to set the permissions properly. A workaround is to

Why does PHP think this folder doesn't exist?

戏子无情 提交于 2019-12-02 09:31:21
I'm having trouble creating a folder and writing into it. if(file_exists("helloFolder") || is_dir("helloFolder")){ echo "folder already exists"; } else { echo "no folder, creating"; mkdir("helloFolder", 0755); } This returns "no folder, creating" even when the folder already exists. Then I get this error: Warning: mkdir() [function.mkdir]: No such file or directory in script.php on line 18 Warning: file_put_contents(/filename.txt) [function.file-put-contents]: failed to open stream: Permission denied in script.php on line 58 What is very strange is that I call three separate scripts that do

Shell (bash) brace expansion with Java's runtime.exec

让人想犯罪 __ 提交于 2019-12-02 07:09:35
问题 I'm trying to get an expansion command to work with runtime.exec, but the braces are being interpreted as literals rather than being expanded. Here's what I'm trying to do: String command = "mkdir -p Foldername{1,2,3}/InnerFolder"; Runtime.getRuntime().exec( new String[] { "sh", "-c", command } ); Unfortunately, that gives me a single folder in my current directory named "Foldername{1,2,3}" instead of "Foldername1", "Foldername2", and "Foldername3". Does anyone know of a way to prevent the

CodeIgniter - Message: mkdir(): Permission denied on Ubuntu

旧街凉风 提交于 2019-12-02 06:00:31
问题 I'd like some help please. I have this PHP script inside my Post_model constructor $dir = FCPATH . 'uploads' . DIRECTORY_SEPARATOR . 'posts'; if (!is_dir($dir)) { mkdir($dir, 0755, true); } which shows me this error: Severity: Warning Message: mkdir(): Permission denied The main idea is that the project has the ability to create users and these users can upload images, or create folders-albums which are stored in the uploads folder. I've been struggling to fix this error the last days and can

php mkdir() in hebrew creates gibrish folder

旧街凉风 提交于 2019-12-02 04:33:28
问题 I am trying to make a dir using a php in english and it's working. But when i try in hebrew, it creats the folder in gibrish like so: ׳”׳•׳¨׳“׳”| ׳׳©׳—׳§ ׳©׳•׳׳˜ how can i fix it? thanks 回答1: PHP has some Unicode support when dealing with strings, but internally PHP's string type is single-byte and does not support multibyte encodings. If you save your PHP file in UTF-8 format, you can output strings in UTF-8 with the proper HTTP encodings, but many of PHP's functions don't support multi-byte

php mkdir() in hebrew creates gibrish folder

痴心易碎 提交于 2019-12-02 01:57:43
I am trying to make a dir using a php in english and it's working. But when i try in hebrew, it creats the folder in gibrish like so: ׳”׳•׳¨׳“׳”| ׳׳©׳—׳§ ׳©׳•׳׳˜ how can i fix it? thanks PHP has some Unicode support when dealing with strings, but internally PHP's string type is single-byte and does not support multibyte encodings. If you save your PHP file in UTF-8 format, you can output strings in UTF-8 with the proper HTTP encodings, but many of PHP's functions don't support multi-byte strings. There are some that do, but still most that do not. I looked around in the PHP source and most of

Shell (bash) brace expansion with Java's runtime.exec

风格不统一 提交于 2019-12-02 00:24:17
I'm trying to get an expansion command to work with runtime.exec, but the braces are being interpreted as literals rather than being expanded. Here's what I'm trying to do: String command = "mkdir -p Foldername{1,2,3}/InnerFolder"; Runtime.getRuntime().exec( new String[] { "sh", "-c", command } ); Unfortunately, that gives me a single folder in my current directory named "Foldername{1,2,3}" instead of "Foldername1", "Foldername2", and "Foldername3". Does anyone know of a way to prevent the braces from being interpreted as literals? Mateusz You're trying to use Bash wildcards. They are