filesystem

Is it possible to capture a "file not found" from another process and then return a file to that process?

I have a legacy application that looks for files in a directory. It does not handle missing files very well. What I want to do is "capture" the file not found errors, and send another file back to the calling app instead. Similar to how you could handle a 404 error on a webserver and return something based on what the requested URL was...

Determining filetype of file in assets folder

Question: How do you programmatically distinguish between directories and regular files in the assets folder? When using AssetManager to access files in the assets folder, it seems impossible to determine if a file is in fact a file or a directory. You get the list of files from the list method and then open the file using the open meth...

Python: problem with tiny script to delete files

I have a project that used to be under SVN, but now I'm moving it to Mercurial, so I want to clear out all the .svn files. It's a little too big to do it by hand, so I decided to write a python script to do it. But it isn't working. def cleandir(dir_path): print "Cleaning %s\n" % dir_path toDelete = [] files = os.listdir(di...

Python script to delete old SVN files lacks permission

I'm trying to delete old SVN files from directory tree. shutil.rmtree and os.unlink raise WindowsErrors, because the script doesn't have permissions to delete them. How can I get around that? Here is the script: # Delete all files of a certain type from a direcotry import os import shutil dir = "c:\\" verbosity = 0; def printCleanM...

How to efficiently manage files on a filesystem in Java?

I am creating a few JAX-WS endpoints, for which I want to save the received and sent messages for later inspection. To do this, I am planning to save the messages (XML files) into filesystem, in some sensible hierarchy. There will be hundreds, even thousands of files per day. I also need to store metadata for each file. I am consider...

How do you pronounce FUSE(File System in Userspace)?

How do you pronounce FUSE? Let me know the pronunciation. Thanks. ...

Understanding how large sqlite databases works on top of jffs2

I am considering using sqlite3 on embedded Linux with JFFS2/NAND instead of using a file based approach. My concern is NAND wear and number of erase operations. So how will e.g. the scenario of deleting or inserting a row in a 12MB database work: Will the whole 12 MB database be re-written when I commit, thus queueing all 12MB of NAN...

How to find the filesystem block size?

I wanted to know a way to find out wich is the disk's block size through a function or a compiler constant in C.. thanks ...

Other way to get folder whose name follows a pattern in php

My OS environment is linux. I have a php file in this folder - /var/www/html (say... test.php) I also have a folder called DATA_SOMENUMBERHERE in the same directory. Inside test.php, I need to find out the SOMENUMBEREHERE. In other words, find the folder whose name starts with DATA_ and get the remainder part of the string. One way ...

Efficient filesystem searching

I am writing a program which searches through all the sub-directories of a given directory. The problem is, is that I know the name of the file that I am looking for (data.txt) but I still need to know all of the (possibly multiple) locations where the file is. I am using this code to search: struct dirent *dp; struct stat s; DIR *dir; ...

R: Brace expansion in Sys.glob()

Is it possible to have R's Sys.glob() function expand braces? What I mean is a pattern similar to /home/foo/{a,b}/bar.txt should find files /home/foo/a/bar.txt and /home/foo/b/bar.txt should they both exist. By default R does not expand the braces. Brace expansion is possible in glob(3) with the GLOB_BRACE flag. I am guessing R is just...

Filesystem-based web content

Hi, I plan to pull my Java web apps's content from a filesystem, for the sake of simplicity of editing. These files will be most probably only a text in a simple markup like JTexy or Markdown. What I plan to implement is a tree-like structure keeping the content of the files. It should be cached and eventually should handle authorizati...

Why is the concatenation of a set of files greater than the sum of the parts?

In an obscure way, it is a programming question. I concatenated several sets of text files in the range of 1MB and found that in each case the concatenated file size was much larger than the sum of the individual files by a large extent (2x-4x times more, even greater for Windows7). Why is this? ...

How to find an FSRef from a directory ID and a volume number?

Given an FSRef of a directory, one can use FSGetCatalogInfo to find the volume reference number and the directory ID. Together, these two numbers should be enough to identify the directory. One way to go the other direction would be use FSMakeFSSpec( vRefNum, dirID, "\p", &fileSpec ) and then FSpMakeFSRef( &fileSpec, &dirRef ). Howeve...

How to display file system in an air application?

Hi All, I'm working on a file sharing application. I want to display one side client file system and other side server(or peer's) file system so that by drag and dropping they can transfer files one system to other. Now I want to display my local file system as it opens main window without any browse or search buttons. Its a window appli...

PHP check if file locked with flock()?

Will fopen() fail if a file exists, but is currently locked with LOCK_EX? Or do I have to open it, and then try and set a lock, in order to determine if one already exists? I've also read that flock() will; pause [the script] untill you get the lock for indefinite amount of time or till your script times out http://www.php.net...

Unix directory structure: managing file name collision

Usually every time `make install' is run, files are not put in a specific directory like /usr/prog1. Instead, the files are put in directories where files from other programs are already in like /usr/lib and /usr/bin. I believe this has been a common practice since long time ago. This practice surely increases the probability of file nam...

Linux - mounting a user space file system(mimicking one :-) ) as a FileSystem

Hi Guys, I have a piece of C code which with a chunk of memory(static array) can mimic file operations (It has APIs similar to fopen/fclose etc). So, any code that is compiled with this mimicking FileSystem can use these APIs as a FileSystem for all their needs :) But I was wondering, if its possible somehow to register these APIs with...

How can I delete a file upon its close in C++ on Linux?

I wish for a file to be deleted from disk only when it is closed. Up until that point, other processes should be able to see the file on disk and read its contents, but eventually after the close of the file, it should be deleted from disk and no longer visible on disk to other processes. ...

Emulating/faking filesystem for testing C code?

I'm looking for the cross-platform way to test some features in my application which required access to the filesystem (to write and read binary data). In the real life my application running on Linux and store special data in /usr/local/etc directory. But main part of the application is cross-platform library and it should be tested bot...