How to check if a path points to an existing file with Java 7’s new File API?

Use the Files class: Files.exists(path); EDIT: to answer your subsequent question, I think the reason that the method is in another class is that Path is an interface, and they wanted to provide an implementation (similar to putting sorting methods in the Collections class instead of the List interface). Not directly related to the question, … Read more

How to get N files in a directory order by last modified date?

Limit just some files => pipe to Select-Object -first 10 Order in descending mode => pipe to Sort-Object LastWriteTime -Descending Do not list directory => pipe to Where-Object { -not $_.PsIsContainer } So to combine them together, here an example which reads all files from D:\Temp, sort them by LastWriteTime descending and select only the … Read more

How do I “normalize” a pathname using boost::filesystem?

Boost v1.48 and above You can use boost::filesystem::canonical: path canonical(const path& p, const path& base = current_path()); path canonical(const path& p, system::error_code& ec); path canonical(const path& p, const path& base, system::error_code& ec); http://www.boost.org/doc/libs/1_48_0/libs/filesystem/v3/doc/reference.html#canonical v1.48 and above also provide the boost::filesystem::read_symlink function for resolving symbolic links. Boost versions prior to v1.48 As mentioned in other answers, … Read more

How to register FUSE filesystem type with mount(8) and fstab?

In general, one “registers” a new mount filesystem type by creating an executable mount.fstype. $ ln -s /usr/bin/vdbfs.py /usr/sbin/mount.vdbfs If vdbfs.py takes mount-ish arguments (i.e. dev path [-o opts]), then mount -t vdbfs and using vdbfs as the 3rd field in fstab will work. If it doesn’t, you can create a wrapper which does take … Read more