How do I check if a directory is writeable in PHP?
Yes, it does work for folders…. Returns TRUE if the filename exists and is writable. The filename argument may be a directory name allowing you to check if a directory is writable.
Yes, it does work for folders…. Returns TRUE if the filename exists and is writable. The filename argument may be a directory name allowing you to check if a directory is writable.
The problem here is that $zip->addFile is being passed the same two parameters. According to the documentation: bool ZipArchive::addFile ( string $filename [, string $localname ] ) filename The path to the file to add. localname local name inside ZIP archive. This means that the first parameter is the path to the actual file in … Read more
To create all intermediate-level destination directories you could use os.makedirs() before copying: import os import shutil srcfile=”a/long/long/path/to/file.py” dstroot=”/home/myhome/new_folder” assert not os.path.isabs(srcfile) dstdir = os.path.join(dstroot, os.path.dirname(srcfile)) os.makedirs(dstdir) # create all directories, raise an error if it already exists shutil.copy(srcfile, dstdir)
Use -d (full list of file tests) if (-d “cgi-bin”) { # directory called cgi-bin exists } elsif (-e “cgi-bin”) { # cgi-bin exists but is not a directory } else { # nothing called cgi-bin exists } As a note, -e doesn’t distinguish between files and directories. To check if something exists and is … Read more
Not sure how you want to represent the tree? Anyway here’s an example which scans the entire subtree using recursion. Files and directories are treated alike. Note that File.listFiles() returns null for non-directories. public static void main(String[] args) { Collection<File> all = new ArrayList<File>(); addTree(new File(“.”), all); System.out.println(all); } static void addTree(File file, Collection<File> all) … Read more
Regular Java file IO: File f = new File(Environment.getExternalStorageDirectory() + “/somedir”); if(f.isDirectory()) { …. Might also want to check f.exists(), because if it exists, and isDirectory() returns false, you’ll have a problem. There’s also isReadable()… Check here for more methods you might find useful.
Using the terms in the documentation, you have specified a root_dir, but not a base_dir. Try specifying the base_dir like so: shutil.make_archive(‘/home/code/test_dicoms’, ‘zip’, ‘/home/code/’, ‘test_dicoms’) To answer your second question, it depends upon the version of Python you are using. Starting from Python 3.4, ZIP64 extensions will be availble by default. Prior to Python 3.4, … Read more
string folderPath = “”; FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog(); if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { folderPath = folderBrowserDialog1.SelectedPath ; }
If Not System.IO.Directory.Exists(YourPath) Then System.IO.Directory.CreateDirectory(YourPath) End If
[*] New Answer (October 2012) There’s no need to manually build the classpath list. Java supports a convenient wildcard syntax for directories containing jar files. java -cp “$LIB/*” (Notice that the * is inside the quotes.) Explanation from man java: As a special convenience, a class path element containing a basename of * is considered … Read more