files

What is the most efficient way to print a file in C to stdout?

I'm stuck on this. Currently I'm using: FILE *a = fopen("sample.txt", "r"); int n; while ((n = fgetc(a)) != EOF) { putchar(n); } However this method seems to be a bit inefficient. Is there any better way? I tried using fgets: char *s; fgets(s, 600, a); puts(s); There's one thing I find wrong about this second method, which is tha...

php script to delete files older than 24 hrs, deletes all files

I wrote this php script to delete old files older than 24 hrs but it deleted all the files including newer ones <?php $path = 'ftmp/'; if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { if ((time()-filectime($path.$file)) < 86400) { if (preg_match('/\.pdf$/i', $file)) { ...

Create a virtual directory for file IO common dialogs from file paths

I've got an archive containing various files. Would there be a method to list out these files in directories (as dictated by their relative paths) in a common dialog (or a custom dialog for that matter) without having to extract the files or create any directory structure on the file system ? The archive reading code is at my disposal. ...

Return Array in ActionScript 3.0 (Flash and Air)

Hey guys, I'm trying to get the name of every files from a specific folder into an array, but I get this error and I can't find why... this may be a stupid question but whatever. TypeError: Error #1009: Cannot access a property or method of a null object reference. Here's my code: import flash.filesystem.File; function getFileLis...

Correct use of Stat on C

Why does this work : char *fd = "myfile.txt"; struct stat buf; stat(fd, &buf); int size = buf.st_size; printf("%d",size); But this does not work: char *fd = "myfile.txt"; struct stat *buf; stat(fd, buf); int size = buf->st_size; printf("%d",size); ...

How to list a 2 million files directory in java without having a out of memory exception

I have to deal with a directory of about 2 million xml's to be processed. I've already solved the processing distributing the work between machines and threads using queues and everything goes right. But now the big problem is the bottleneck of reading the directory with the 2 million files in order to fill the queues incrementally. ...

In Mercurial, how do I pick specific files from a named branch to merge back with default?

I have a big named branch with a lot of changes. Some of these changes are non-destructive so I want to pick these specific files out first, and merge them with default as soon as possible. (Then later, the destructive changes are merged as well.) In Git I would create another branch and squash all changesets outside of the index, then ...

Help with Batch Files?

What are batch files useful for? They just seem to be used to make viruses and other things...but it seems like shell scripting to me. Whats the uses for batch files? ...

ASP.Net MVC FileStreamResult, valid chars for FileDownloadName

Hi, I have an action method that returns a FileStreamResult, the download works fine, the problem is that although I set the FileDownloadName property of the result object, some of the files are downloaded with another name (specifically the last part of the address of the page I'm working on. e.g. in the page "http://localhost:5479/Ite...

iPhone 4.0 OS writing to visible file in sandbox

I was working prior to 4.0 OS with my iPhone and and writing to media/DCIM/100APPLE. I could download these files using DiskAid. This was a perfect dev solution. My provider without asking upgraded my phone to 4.0. Bang, I am no longer able to write anywhere visible. In distribution we will be using the temporary directory, no probl...

Best way to open an URL in Vim

Lets say that you have either URL or a link on a webpage that is a text file. How would be the easiest way for the user to be able to open that file in a Vim? Right click and save link as? Use a specific file extension that defaults to Vim? Command line command? ...

Adding files to redmine via command line

We have an automatic build system that spits out packages, regression-tested & wrapped into a neat installer, ready for end-users to d/l & deploy. We do tracking of end user support requests/bug reports via redmine. So far we uploaded the packages manually to the resp. 'Files' section of the redmine project, via the web interface. What ...

BASH script to copy files based on date, with a catch...

Let me explain the tree structure: I have a network directory where several times a day new .txt files are copied by our database. Those files sit on directory based on usernames. On the local disk I have the same structure (directory based on usernames) and need to be updated with the latest .txt files. It's not a sync procedure: I copy...

Cross platform recursive file list using C++?

What is the most efficient way to recursively list files in a specific directory and its subdirectories? Should I use the standard library, or use some third party? I want this because I use v8 as a JavaScript engine, and I want to execute all scripts in some directory (and its subdirectories). If there's any built-in way to do that in...

Django css files

i want to create some css styles for my Django templates. Each view will have a css associated, but there will be zones that are not associated to any views in my template. How can i load the css files? is there enough having them declared in the Media of my view, and loading them in the header of the html? Also, is it a correct approa...

Redirect directory to file using htaccess?

I'm trying to do something like this... Redirect mysite.com/directory/ To mysite.com/directory/do But ONLY when "/directory/" is opened without pointing to a file. I am aware that "DirectoryIndex" can help with this, but I want the file's name (which is "do") to appear in the url the users sees. Is there a way to accomplish this with ....

Files in directory in C++

How to get all files in a given directory using C++ on windows? Note: I found methods that use dirent.h but I need a more standard way... Thanks ...

Save files (pictures, music, movies) in a Container file.

I am currently learning C# during my studies and I am writing a small movie database application in it. I know its not good to save pictures (etc) inside the database, especially when adding movie covers that are rather big. But I don't want the files to just get saved in a folder as this creates a mess if more and more movies are added ...

PHP + Wordpress - get a list of files from a directory

Hi Are there any native WP functions that are able to list files based by extension from a directory? if not, how do I do this with php? I want to get the file names of all .css files from a certain folder ...

android: can't write to files dir but can in package dir

I'm trying to save an object in a file but the file doesn't appear on the device and I don't get an exception either. public static void save(Context ctx) { Log.i("App serialization", "Saving to settings.ser: " + ctx.getFileStreamPath("settings.ser")); FileOutputStream fos = null; ObjectOutputStream out = null; try { ...