filesystems

Getting absolute path of a file

How can I convert a relative path to an absolute path in C on Unix? Is there a convenient system function for this? On Windows there is a GetFullPathName function that does the job, but I didn't find something similar on Unix... ...

What's the best way to check if a file exists in C? (cross platform)

Is there a better way than simply trying to open the file? int exists(const char *fname) { FILE *file; if (file = fopen(fname, "r")) { fclose(file); return 1; } return 0; } ...

How do you determine the ideal buffer size when using FileInputStream?

I have a method that creates a MessageDigest (a hash) from a file, and I need to do this to a lot of files (>= 100,000). How big should I make the buffer used to read from the files to maximize performance? Most everyone is familiar with the basic code (which I'll repeat here just in case): MessageDigest md = MessageDigest.getInstance(...

CRC checks for files

I'm working with a small FAT16 filesystem, and I want to generate CRC values for indidual XML files which store configuration information. In case the data changes or is corrupted, I want to be able to check the CRC to determine that the file is still in it's original state. The question is, how do I put the CRC value into the file, wit...

Checking files for errors

I have lots of files in different formats (mostly pdf files) and I need to check if they can be opened without errors and get a list of those that are broken. Other than opening them all separately is there a way to find out which won't open / are corrupt? ...

xcopy "copies only files that don't already exist on destination"

Does anyone know how to do this? I can copy only files that DO exist on the destination, but not the other way around... any ideas? More information I have 3 gigs of files on System A. I have 4 gigs of files on System B. Many of the files are the same I only want to copy the files from System B to System A that don't already exist on...

SetSystemFileCacheSize and RtlCompressBuffer

I have a problem where the system cache grows too big such that my server applications do nt have enough free RAM. This is a known issue in 64-bit Windows Server 2003. Using SetSystemFileCacheSize API works to limit the max size of the system file cache, BUT, when it is limited, then suddenly a system thread starts up running RtlCompre...

Detect changes in a filesystem since last scan

Programs that index filesystems seem to know which parts have changed since their last index and only rescan that part. How can I determine where the filesystem/files have changed since my last index. Don't care what language you answer in but I'm thinking c and windows. An example of such a program is Sequoia View which generates a tre...

How to determine if a directory is on same partition

Say I have an input file, and a target directory. How do I determine if the input file is on the same hard-drive (or partition) as the target directory? What I want to do is the copy a file if it's on a different, but move it if it's the same. For example: target_directory = "/Volumes/externalDrive/something/" input_foldername, input_f...

OS X: Determine Trash location for a given path

Simply moving the file to ~/.Trash/ will not work, as if the file os on an external drive, it will move the file to the main system drive.. Also, there are other conditions, like files on external drives get moved to /Volumes/.Trash/501/ (or whatever the current user's ID is) Given a file or folder path, what is the correct way to dete...

What is the difference between file and record in OS's view?

In terms of general operating system concepts , What is the difference between a file and a record? How the OS will manage them? I know what a file is and what a record is but how it is distinguished in an OS? ...

Quickly create a large file on a linux system?

How can I quickly create a large file on a Linux (RHEL) system? dd will do the job, but reading from /dev/zeo and writing to the drive can take a long time when you need a file several hundreds of GB 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 wan...

handling lots of temporary small files

I have a web server which saves cache files and keeps them for 7 days. The file names are md5 hashes, i.e. exactly 32 hex characters long, and are being kept in a tree structure that looks like this: 00/ 00/ 00000ae9355e59a3d8a314a5470753d8 . . 00/ 01/ You get the idea. My problem is that deleting old files is taking ...

Best distributed filesystem for commodity linux storage farm

I have a lot of spare intel linux servers laying around (hundreds) and want to use them for a distributed file system in a web hosting and file sharing environment. This isn't for a HPC application, so high performance isn't critical. The main requirement is high availability, if one server goes offline, the data stored on it's hard dr...

Sparse files in WinXP SP3

Suddenly, we found out that WinXP SP3 didn't allow to create NTFS sparse file in user-mode application. Namely, DeviceIoControl with FSCTL_SET_SPARSE returns with error 0x57 (ERROR_INVALID_PARAMETER). The same code works well in SP2. Also, it's all ok if make the same calls from kernel-mode (both in SP3 and SP2). Google says nothing abo...

Java in Eclipse: Where do I put the images (on the filesystem) that I want to load into an ImageIcon

I know the image file needs to be where the getClass().getResource(filename) can find it, but I don't know where that is. I'm interested both in where to put the images on the filesystem itself, and how to go about using Eclipse's functionality to set up the resources. ...

AccessControlException when attempting to delete a file

We have a java web service application that uses log4j to do logging. An exception gets thrown when log4j tries to delete its rolling log files Exception:java.security.AccessControlException: access denied (java.io.FilePermission /var/opt/SUNWappserver/domains/domain1/ applications/j2ee-modules/ourwebservice/WEB-INF/logs/IMWrapper.log....

Debugging Filesystem access

I'm looking for a Windows tool that is able to log every action (read & write) that were made to a specific path inside the local Filesystem in order to debug a program (find out why it is sometimes slow and sometimes not). In theory it could work like a virus scanner that is recognizing every file that any of the running programs do rea...

How to guarantee files that are decrypted during run time are cleaned up?

Using C or C++, After I decrypt a file to disk- how can I guarantee it is deleted if the application crashes or the system powers off and can't clean it up properly? Using C or C++, on Windows and Linux? ...

definition of filename ?

After years of programming it's still some of the simple things that keep tripping me up. Is there a commonly agreed definition of filename ? Even the wikipedia article confuses the two interpretations. It starts by defining it as 'a special kind of string used to uniquely identify a file stored on the file system of a computer'. Tha...