files

How to get rid of . and .. while scaning the folder creating an array in php?

If you scan a folder containing other folders AND files, how do you get rid of . and .. and files? How do you put in array only folders WITHOUT . and ..? I would like to use regular expression, but I'm newbie and I can't get it right. My code is now this but doesn't work: if(fnmatch("\.{1,2}",$dir_array[$i]) || is_file($dir_array[$i]...

Command line to delete matching files and directories recursively

How can I recursively delete all files & directories that match a certain pattern? e.g. remove all the ".svn" directories and the files they contain? (Sadly DOS only) ...

File Copying optimization through multiple threads

Can you make file copying faster through multiple threading? Edit: To clarify, suppose you were implementing CopyFile(src, tgt). It seems logical that under certain circumstances you could use multiple threads to make it go faster. Edit Some more thoughts: Naturally, it depends on the HW/storage in question. If you're copying from on...

PHP Pass File Handle to user so that file downloads & saves to their machine

Hello all, I am downloading a file from another server. I wish to push this file to my users rather than saving it to my server. In other words, pass them the file handle so it just passes through my server and saves to their machine. How can I do this? I have this so far: $handle = fopen($_GET['fileURL'], 'r'); $filename = stream_ge...

How do I programatically change the security attributes of a file so that any user can delete the file.

I have a server written in C# that makes use of impersonation. I would like to know how I can change the security attributes of a file so that any user can delete it. My server impersonates a user and then creates a temporary file. Later on I need to delete the file but at that point, I am no longer impersonating the user that created ...

what is the optimal way to assemble a file?

I've large number of small files with sequential filenames & i want to create a single file out of it. What is the fastest way to do this? e.g. 1.tgz.1 1.tgz.2 1.tgz.3 =========> 1.tgz ...

Renaming File on another server as user downloads it

Hello all, I am allowing users to download a file from another server just by giving them the link. However, the files are always named "file.zip" when users try to download it. I was hoping I could use maybe JavaScript to rename the file for them to something more appropriate. How can I do this? Is this possible? Would appreciate a...

Efficiently retrieving and filtering files.

This earlier SO question talks about how to retrieve all files in a directory tree that match one of multiple extensions. eg. Retrieve all files within C:\ and all subdirectories, matching *.log, *.txt, *.dat. The accepted answer was this: var files = Directory.GetFiles("C:\\path", "*.*", SearchOption.AllDirectories) .Wh...

Renaming File on another server as user downloads it [2] - using PHP

I have asked this question today already but this time I want to know if I can achieve this via PHP since Javascript wasn't up to it. I have a link to a file on another server. If i provide this link to my users the headers are pushed out to download that file from that server. Is there a way for me to capture those headers and file an...

Deleting empty (zero-byte) files

What's the easiest/best way to find and remove empty (zero-byte) files using only tools native to Mac OS X? ...

Is there any ordinary reason to use open() instead of fopen()?

I'm doing a small project in C after quite a long time away from it. These happen to include some file handling. I noticed in various documentation that there are functions which return FILE * handles and others which return (small integer) descriptors. Both sets of functions offer the same basic services I need so it really does not mat...

Delete on close files

Language used: C# Theory: I want to create a file with the flag FileOptions.DeleteOnClose in a temporary folder. The file is successfully created and I write dato onto it, the next step is to launch the application associated with the file Process.Start(...) and allow the user to inspect the document, finally I close my handle and as so...

Save remote file that pushes headers to force download

Hello all, I can download remote files using PHP but how do you download from a link that pushes headers out? I mean, you can click on some links and it will force a download and present you with dialog box to save the file. How can I download and save this sort of thing using PHP? Any examples or links to tutorials would be great sinc...

How to retrieve the size of a file before uploading it?

I have an file input tag in my web app. I'd like to check that the file isn't too big before sending it to the server. Of course, I still have validation server side. Is there any way to do this with JavaScript? It must work in IE7+ and FF3+. Thank you. EDIT: somefileinputobject.files[0].filesize works in FF, but not IE. ...

How can I merge lines in a large, unsorted file without running out of memory in Perl?

I have a very large column-delimited file coming out of a database report in something like this: field1,field2,field3,metricA,value1 field1,field2,field3,metricB,value2 I want the new file to have combine lines like this so it would look something like this: field1,field2,field3,value1,value2 I'm able to do this using a hash. In t...

How can I make changes to only the first line of a file?

I would like to know which pattern can I use in sed to make changes in the first line of huge files (~2 GB). The preference for sed is only because I assume it must be faster than a Python or Perl script. The files have the following structure: field 1, field 2, ... field n data and, given the likelihood of having spaces in the ident...

how to delete all files from current directory including current directory

how can I delete all files and sub directories from current directory including current directory? ...

Java IO implementation of unix/linux "tail -f"

I'm wondering what techniques and/or library to use to implement the functionality of the linux command "tail -f ". I'm essentially looking for a drop in add-on/replacement for java.io.FileReader. Client code could look something like this: TailFileReader lft = new TailFileReader("application.log"); BufferedReader br = new BufferedRea...

How can I reliably guarantee access to a file/folder?

-What is the most foolproof way of ensuring the folder or file I want to manipulate is accessible (not read-only)? -I know I can use ACL to add/set entries (make the file/folder non-readonly), but how would I know if I need to use security permissions to ensure file access? Or can I just add this in as an extra measure and handle the ex...

Deleting a file in C#

Seems like it should a really easy topic, all the examples everywhere are just a couple of lines however no decent explainations, and thus I keep running into the same error without a solution. In short this part of the applicaion runs like so Pulls images from db Creates actual images files in a temp folder creates pdf with images i...