What is the Unix command to create a hardlink to a directory in OS X?

I agree that hard-linking folders/directories can cause problems if not careful, but they have a very definite advantage – Time Machine is a perfect example. Without them it simply would not be practical as the duplication of redundant versions of files would very quickly consume even the largest of disks. Snow Leopard can create hard … Read more

Can I use a mask to iterate files in a directory with Boost?

EDIT: As noted in the comments, the code below is valid for versions of boost::filesystem prior to v3. For v3, refer to the suggestions in the comments. boost::filesystem does not have wildcard search, you have to filter files yourself. This is a code sample extracting the content of a directory with a boost::filesystem‘s directory_iterator and … Read more

Is there a cross-platform Java method to remove filename special chars?

As suggested elsewhere, this is not usually what you want to do. It is usually best to create a temporary file using a secure method such as File.createTempFile(). You should not do this with a whitelist and only keep ‘good’ characters. If the file is made up of only Chinese characters then you will strip … Read more

Trying to create a file in Android: open failed: EROFS (Read-only file system)

I have tried this with and without the WRITE_INTERNAL_STORAGE permission. There is no WRITE_INTERNAL_STORAGE permission in Android. How do I create this file for writing? You don’t, except perhaps on a rooted device, if your app is running with superuser privileges. You are trying to write to the root of internal storage, which apps do … Read more

Creating temp files in scripts: Advantages of mktemp over touch-ing a file? [closed]

mktemp randomizes the name. It is very important from the security point of view. Just imagine that you do something like: echo something > /tmp/temporary-file in your root-running script. And someone (who has read your script) does ln -s /etc/passwd /tmp/temporary-file before. This results in /etc/passwd being overwritten, and potentially it can mean different unpleasant … Read more

copy all files and folders from one drive to another drive using DOS (command prompt)

xcopy “C:\SomeFolderName” “D:\SomeFolderName” /h /i /c /k /e /r /y Use the above command. It will definitely work. In this command data will be copied from c:\ to D:, even folders and system files as well. Here’s what the flags do: /h copies hidden and system files also /i if destination does not exist and … Read more