subdirectory

Git Ignore everything in a directory except subfolders

巧了我就是萌 提交于 2019-11-29 04:45:01
问题 This is my folder structure: data/ .gitignore uploads/ .gitignore I would like to commit the folders but not the files inside them. So I add a .gitignore files in every folder with the following content: # Ignore everything in this directory * # Except this file !.gitignore The problem is that * matches also on directories so git tracks only data/.gitignore 回答1: Please don't misuse .gitignore files. Better stick to default ways to go on this, so later developers can quickly get into your

Non-recursive way to get all files in a directory and its subdirectories in Java

半城伤御伤魂 提交于 2019-11-28 23:31:32
I am trying to get a list of all files in a directory and its subdirectories. My current recursive approach is as follows: private void printFiles(File dir) { for (File child : dir.listFiles()) { if (child.isDirectory()) { printFiles(child); } else if (child.isFile()) { System.out.println(child.getPath()); } } } printFiles(new File("somedir/somedir2")); However, I was hoping there was a non-recursive way (an existing API call, maybe) of doing this. If not, is this the cleanest way of doing this? Ryan Gross You can always replace a recursive solution with an iterative one by using a stack (for

Remove all files, folders and their subfolders with php [duplicate]

微笑、不失礼 提交于 2019-11-28 23:24:54
This question already has an answer here: Delete directory with files in it? 33 answers I need a script which can remove a whole directory with all their subfolders, files and etc. I tried with this function which I found in internet before few months ago but it not work completely. function deleteFile($dir) { if(substr($dir, strlen($dir)-1, 1) != '/') { $dir .= '/'; } if($handle = opendir($dir)) { while($obj = readdir($handle)) { if($obj != '.' && $obj != '..') { if(is_dir($dir.$obj)) { if(!deleteFile($dir.$obj)) { echo $dir.$obj."<br />"; return false; } } elseif(is_file($dir.$obj)) { if(

C# Remove all empty subdirectories

风格不统一 提交于 2019-11-28 18:26:51
问题 I have a task to clean up a large number of directories. I want to start at a directory and delete any sub-directories (no matter how deep) that contain no files (files will never be deleted, only directories). The starting directory will then be deleted if it contains no files or subdirectories. I was hoping someone could point me to some existing code for this rather than having to reinvent the wheel. I will be doing this using C#. 回答1: Using C# Code. static void Main(string[] args) {

List all files and directories in a directory + subdirectories

隐身守侯 提交于 2019-11-28 16:56:01
I want to list every file and directory contained in a directory and subdirectories of that directory. If I chose C:\ as the directory, the program would get every the name of every file and folder on the hard drive that it had access to. A list might look like fd\1.txt fd\2.txt fd\a\ fd\b\ fd\a\1.txt fd\a\2.txt fd\a\a\ fd\a\b\ fd\b\1.txt fd\b\2.txt fd\b\a fd\b\b fd\a\a\1.txt fd\a\a\a\ fd\a\b\1.txt fd\a\b\a fd\b\a\1.txt fd\b\a\a\ fd\b\b\1.txt fd\b\b\a Ruslan F. string[] allfiles = Directory.GetFiles("path/to/dir", "*.*", SearchOption.AllDirectories); where *.* is pattern to match files If the

Use a subdirectory as root with htaccess in Apache 1.3

我们两清 提交于 2019-11-28 14:27:46
问题 I'm trying to deploy a site generated with Jekyll and would like to keep the site in its own subfolder on my server to keep everything more organized. Essentially, I'd like to use the contents of /jekyll as the root unless a file similarly named exists in the actual web root. So something like /jekyll/sample-page/ would show as http://www.example.com/sample-page/, while something like /other-folder/ would display as http://www.example.com/other-folder. My test server runs Apache 2.2 and the

Recursive method to search through folder tree and find specific file types

风流意气都作罢 提交于 2019-11-28 13:59:17
So I am writing a code that locates certain information on Protein databases. I know that a recursive folder search is the best possible way to locate these files, but I am very new to this language and have been told to write in Java (I normally do C++) SO this being said, what method would i use to: First: Locate the folder on desktop Second: Open each folder and that folders subfolders Third: Locate files that end with the ".dat" type (because these are the only files that have stored the Protein information Thanks for any and all help you can provide java.io.File is "An abstract

.htaccess RewriteRule not working in subdirectory

情到浓时终转凉″ 提交于 2019-11-28 11:05:27
I'm programming the new version of my website and I'm trying to get .htaccess to rewrite properly. My new site is stored here: www.example.com/storage/new/ I need to rewrite these URLs: www.example.com/storage/new/welcome/ -> index.php?action=welcome www.example.com/storage/new/page/name/ -> index.php?action=page&url=name www.example.com/storage/new/post/name/ -> index.php?action=post&url=name This is my .htaccess file: RewriteEngine On RewriteRule ^/welcome/$ index.php?action=welcome [L] RewriteRule ^/page/([a-zA-Z0-9]+)/$ index.php?action=page&url=$1 [L] RewriteRule ^/post/([a-zA-Z0-9]+)/$

git-archive a subdirectory --

杀马特。学长 韩版系。学妹 提交于 2019-11-28 08:19:59
I'm using git-archive to archive a subdirectory in a git repo, like so: git archive -o ../subarchive.zip HEAD subdir/* However the resulting archive maintains the subdir/ directory structure, i.e. the contents are: subdir/ whatever.js morestuff.js When I actually want whatever.js and morestuff.js at the root of the archive. How do? Thanks. You can do that like this: git archive -o ../subarchive.zip HEAD:subdir By the way, an easy way to play with the command and see what it will generate is if you use it in this form: git archive --format=tar HEAD:subdir | tar t git archive --format=tar HEAD

how to deploy django under a suburl behind nginx

不打扰是莪最后的温柔 提交于 2019-11-28 08:14:16
I have a django application running on http://localhost:12345 . I'd like user to access it via url http://my.server.com/myapp . I use nginx to reverse proxy to it like the following: ... ... server_name my.server.com; location /myapp { rewrite /myapp(.*) $1 break; ... ... # proxy param proxy_pass http://localhost:12345; } ... ... The question is, when configured like the above, how to make the urls in my response pages to have a prefix of "/myapp" so that the nginx can direct them correctly to myapp. E.g., the urls in a page like "/foo/far" ought to be changed to "/myapp/foo/bar" to allow