directory

Directory recursion

自闭症网瘾萝莉.ら 提交于 2019-12-18 17:26:53
问题 If you need to recursively traverse a directory tree, there are two ways to do it: Build up pathnames of increasing length as you go, .../.../... etc. Use chdir to step down into each directory as you come to it, so you are never dealing with pathnames longer than two components. The first method strikes me as more obvious, and might be more robust against untoward events like something being unmounted while you are halfway through it. On the other hand, looking over the code for the GNU find

How can I check whether this is directory-path or any filename-path?

笑着哭i 提交于 2019-12-18 17:12:10
问题 by this Why does fopen("any_path_name",'r') not give NULL as return? i get to know that in linux directories and files are considered to be file. so when i give any directory-path or file-path in fopen with read mode it doesnt give NULL file descriptor and? so how can i check that whether it is dirctory path or file-path ? if i am getting some path from command argument? 回答1: man 2 stat : NAME fstat, fstat64, lstat, lstat64, stat, stat64 -- get file status ... struct stat { dev_t st_dev; /*

Add 'Delete empty folders' to Windows context menu

一个人想着一个人 提交于 2019-12-18 16:52:31
问题 I'd like to add to context menu this nice shell script that automatically deletes all empty folders and subfolders under the folder it is run from: for /f "usebackq delims=" %%d in (`"dir /ad/b/s | sort /R"`) do rd "%%d" To add such an item to (directories) context menu I should run a file with reg extension having a content similar to Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\shell\Delete empty folders] [HKEY_CLASSES_ROOT\Directory\shell\Delete empty folders\Command]

How to Limit The Depth of a Recursive Sub-Directory Search

安稳与你 提交于 2019-12-18 16:50:41
问题 I've got a function that currently grabs all folders and sub-folders to check the ACL's for a small tool I'm building but I'm pulling my hair out trying to figure out how to limit the depth that it can go to. For example you have a folder that goes 4 levels deep but I want to be able to only grab 3 levels of it for ACL's. Currently I have it coded thusly: private void StepThroughDirectories(string dir) { string[] directories = Directory.GetDirectories(dir); try { foreach (string d in

Recursively walking through a directory tree and listing file names

佐手、 提交于 2019-12-18 15:34:12
问题 I'm trying to walk through a whole directory tree and print out all the file names on a listbox control. I wrote some code but there are errors. Not sure what I'm doing wrong. By the way, this is in C# using WPF in Visual Studio. Here is the whole project solution in Visual Studio: http://tinyurl.com/a2r5jv9 Here is the code from MainWindow.xaml.cs if you don't want to download the project solution: http://pastebin.com/cWRTeq3N I'll paste the code here as well. public partial class MainWindow

get directory from full path

China☆狼群 提交于 2019-12-18 14:01:43
问题 If i have: C:\temp\foo\bar\ ( NOTE: bar is a directory) how can i parse out: bar 回答1: I figured it out. DirectoryInfo info = new DirectoryInfo(sourceDirectory_); string currentDirectoryName = info.Name; 回答2: Try System.IO.Path.GetFileName("C:\\temp\\foo\\bar"); 回答3: Just use: string dirname = new DirectoryInfo(@"C:\temp\foo\bar\").Name; According to MSDN this returns the name of the directory, not the full path. Link to MSDN Library Hope this helps......... 回答4: It looks like a bunch of

java hsperfdata directory [closed]

筅森魡賤 提交于 2019-12-18 13:51:09
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Java creates hsperfdata directory usually in the /tmp directory. What purpose does this directory serve? What is the effect on the JVM if this directory is accidentally deleted? 回答1: That directory is part of a Java performance counter. There's a JVM argument for turning it off: see this related question on

Git merge from a specific folder only

随声附和 提交于 2019-12-18 13:48:51
问题 I've created a rails website for client X. I now have a client, Y, who wants a website that does the exact same thing as client X, but with a different skin. I made a git branch from clientXcode and called it clientYcode. I then did all the changes to the views to make it look different, and lala, the same website with a different skin. Now here's what I don't understand about git: I've made many changes to clientXcode in the views, models, and controllers; and now I want to merge those

Best way to replace a whole directory tree in Subversion?

天涯浪子 提交于 2019-12-18 13:16:32
问题 Within my Subversion project I have a few directories that contain other open source projects that my code needs. For example ffmpeg, freetype, matrixssl and a few others. What is the best way to update SVN to hold the the latest version of one of these projects? Essentially I will be doing the following (using ffmpeg as an example): 1) Rename current ffmpeg folder to ffmpeg.old 2) Download new version of ffmpeg from net 3) Make sure it and my code compile and work fine together 4) Update

How do I create a directory and parent directories in one Perl command?

余生颓废 提交于 2019-12-18 12:55:32
问题 In Perl, how can I create a subdirectory and, at the same time, create parent directories if they do not exist? Like UNIX's mkdir -p command? 回答1: use File::Path qw(make_path); make_path("path/to/sub/directory"); The deprecated mkpath and preferred make_path stemmed from a discussion in Perl 5 Porters thread that's archived here. In a nutshell, Perl 5.10 testing turned up awkwardness in the argument parsing of the makepath() interface. So it was replaced with a simpler version that took a