file

How to rebuild a BST from a file

My C++ program creates an unbalanced BST from user input, and saves it do disk. It does this by first indexing each node by doing a pre-order traversal and assigning each node a unique number. Next, it outputs the BST to a file. It does this by doing a pre-order traversal and then for each node printing to file the data value, the ind...

create array of pointers to files

How would I go about making an array of file pointers in C? I would like to create an array of file pointers to the arguments of main... like a1.txt, a2.txt, etc... So I would run ./prog arg1.txt arg2.txt arg3.txtto have the program use these files. Then the argument for main is char **argv From argv, I would like to create the array of...

Retrieving the name of the file that is associated with a file pointer

Assume I have a file pointer FILE* myfile. Is there a way to retrieve the name of the file where myfile is reading from or writing to? ...

Cache byte[] in a hashtable vs MemoryStreams.

We are reading huge files in to memorystream and reusing them across mulitple locations in the code. Just wondering if it is a better idea to get byte[] of files and store them in a hashtable for such a scenario. This way we could close the memorystream when we are done and just recreate one from hashtable when needed. Just wondering if ...

Using Djangos ImageField to upload an image, rename it to a random filename and create thumbnail

Hay guys, I've wrote a simple upload method for my pictures class Picture(models.Model): path = models.CharField(max_length=200) filename = models.CharField(max_length=200) car = models.ForeignKey('Car') thumb_path = models.CharField(max_length=200) created_on = models.DateField(auto_now_add=True) updated_on = mo...

setting content type in java for file download

Hi... In my application i like to provide file download facility. I set the file types to response.setContentType. How can I set the content types for almost all known file types? Is there any easy way? or I need to set it manually like i do now, which is given below. if (pictureName.indexOf("jpg") > 0) { re...

Analog of PHP "MAX_FILE_SIZE" param for JSP

Is there analog of PHP "MAX_FILE_SIZE" parameter for JSP? It's needed to perform validation on UI before upload process triggered on backend. ...

ImageField upload_to not working

Hay guys, I'm using an ImageField to upload files, however when i add upload_to to the ImageField it doesnt append the directory to the MEDIA_ROOT MEDIA_ROOT = '/Users/username/Django/site/assests/' picture = models.ImageField(upload_to='uploads') i get an error saying No such file or directory: u'/Users/username/Django/site/assest...

Race condition when calling FSDeleteObject

I have implemented a "safe save" operation that goes something like this: Save some data to temporary file A Copy contents of A to final destination B Delete A I have a race condition at step 3 where Mac OS X will occasionally come back with error -47 (fBsyErr) when trying to delete the file using FSDeleteObject. I am completely conf...

How do I write to a hidden file?

I am using the TextWriter to try to write to a hidden file, and it is throwing an exception. I can't seem to figure out how to write to a hidden file. using (TextWriter tw = new StreamWriter(filename)) { tw.WriteLine("foo"); tw.Close(); } Exception: Unhandled Exception: System.UnauthorizedAccessException: Access to the path ...

How can I download over FTP all the XML files in a directory?

I'm wondering how I would download all _*.xml_ files from a folder I have set up on an FTP server using Net::FTP. I have seen that glob() would be the best way, but I cannot quite wrap my head around the logic. Basically, I need to check if there are XML files in the folder. If not, wait 5 seconds, and check again. Once the files show u...

Separating ASCII text from binary content in a file

I have a file that has both ASCII text and binary content. I would like to extract the text without having to parse the binary content as the binary content is 180MB. Can I simply extract the text for further manipulation ... what would be the best way of going about it. The ASCII is at the very beginning of the file. ...

Replace a word in a file

Hi, I am new to Python programming... I have a .txt file....... It looks like.. 0,Salary,14000 0,Bonus,5000 0,gift,6000 I want to to replace the first '0' value to '1' in each line. How can I do this? Any one can help me.... With sample code.. Thanks in advance. Nimmyliji ...

Adding text to start of each new line in a .txt file

I would like to add a predefined text to each new line on a text file and create a new text file with the added text. Please help. ...

Vbscript. Variable looses its content?

...

High volume large file uploads

Trying to find a suitable method of accepting large file uploads that has to be scalable. By large I mean up to 5-10gb files. I also need to process the files afterwards. I was thinking of using PHP and HTTP PUT for uploads, then passing the stream of data directly to disk. I'd then process the file afterwards. Doing a custom server an...

iPhone Or Mac Header File?

Hello all, Just a small question... How is it that you tell the difference between an iPhone header file which you can use in conjunction with iPhone development, or a mac specific header file. Many thanks, Stu ...

How to execute some code when a file is modified using python?

Hello, I want to execute one funtion each time a file gets written with new data (gets modified) and I'm using Python. How can I do it? Thanks in advance! :) ...

Pythonic way to check if a file exists?

Which is the preferred way to check if a file exists and if not create it? ...

concatenate files without copying their contents

Hi, (In C/C++/Linux) Is there a way to concatenate file A and file B (or actually append one A's content to that of B) only by altering the file system without the overhead of data copying? File A then can be discarded. Thanks ...