EzDevInfo.com

filesystems interview questions

Top filesystems frequently asked interview questions

How to recursively find the latest modified file in a directory?

It seems that ls doesn't sort the files correctly when doing a recursive call:

ls -altR . | head -n 3

How can I find the most recently modified file in a directory (including subdirectories)?


Source: (StackOverflow)

How can I get a writable path on the iPhone?

I am posting this question because I had a complete answer for this written out for another post, when I found it did not apply to the original but I thought was too useful to waste. Thus I have also made this a community wiki, so that others may flesh out question and answer(s). If you find the answer useful, please vote up the question - being a community wiki I should not get points for this voting but it will help others find it

How can I get a path into which file writes are allowed on the iPhone? You can (misleadingly) write anywhere you like on the Simulator, but on the iPhone you are only allowed to write into specific locations.


Source: (StackOverflow)

Advertisements

Open directory dialog

I want the user to select a directory where a file that I will then generate will be saved. I know that in WPF I should use the OpenFileDialog from Win32, but unfortunately the dialog requires file(s) to be selected - it stays open if I simply click OK without choosing one. I could "hack up" the functionality by letting the user pick a file and then strip the path to figure out which directory it belongs to but that's unintuitive at best. Has anyone seen this done before?


Source: (StackOverflow)

How can I find all of the distinct file extensions in a folder hierarchy?

On a Linux machine I would like to traverse a folder hierarchy and get a list of all of the distinct file extensions within it.

What would be the best way to achieve this from a shell?


Source: (StackOverflow)

How do I check if a given string is a legal / valid file name under Windows?

I want to include a batch file rename functionality in my application. A user can type a destination filename pattern and (after replacing some wildcards in the pattern) I need to check if it's going to be a legal filename under Windows. I've tried to use regular expression like [a-zA-Z0-9_]+ but it doesn't include many national-specific characters from various languages (e.g. umlauts and so on). What is the best way to do such a check?


Source: (StackOverflow)

Node.js check if path is file or directory

I can't seem to get any search results that explain how to do this.

All I want to do is be able to know if a given path is a file or a directory (folder).


Source: (StackOverflow)

Get a filtered list of files in a directory

I am trying to get a list of files in a directory using Python, but I do not want a list of ALL the files.

What I essentially want is the ability to do something like the following but using Python and not executing ls.

ls 145592*.jpg

If there is no built-in method for this, I am currently thinking of writing a for loop to iterate through the results of an os.listdir() and to append all the matching files to a new list.

However, there are a lot of files in that directory and therefore I am hoping there is a more efficient method (or a built-in method).


Source: (StackOverflow)

How to copy a file from one directory to another using PHP?

Say I've got a file test.php in foo directory as well as bar. How can I replace bar/test.php with foo/test.php using PHP? I'm on Windows XP, a cross platform solution would be great but windows preferred.


Source: (StackOverflow)

Getting the folder name from a path

string path = "C:/folder1/folder2/file.txt";

What objects or methods could I use that would give me a result of folder2?


Source: (StackOverflow)

Quickly create a large file on a Linux system?

How can I quickly create a large file on a Linux (Red Hat Linux) system? dd will do the job, but reading from /dev/zero and writing to the drive can take a long time when you need a file several hundreds of GBs in size for testing... If you need to do that repeatedly, the time really adds up.

I don't care about the contents of the file, I just want it to be created quickly. How can this be done?

Using a sparse file won't work for this. I need the file to be allocated disk space.


Source: (StackOverflow)

Checking if a folder exists (and creating folders) in Qt, C++

In Qt, how do I check if a given folder exists in the current directory?
If it doesn't exist, how do I then create an empty folder?


Source: (StackOverflow)

NTFS performance and large volumes of files and directories

How does Windows with NTFS perform with large volumes of files and directories?

Is there any guidance around limits of files or directories you can place in a single directory before you run into performance problems or other issues? e.g. is a folder with 100,000 folders inside of it an ok thing to do


Source: (StackOverflow)

How to create a directory using Ansible?

How to create a directory www at /srv on a debian based system using a Ansible playbook?


Source: (StackOverflow)

How to read and write into file using JavaScript

Can anybody give the sample code to read and write the file using JavaScript?


Source: (StackOverflow)

How to check whether a file exists using Python

How do I check whether a file exists, using Python, without using a try-catch statement?


Source: (StackOverflow)