I'm making a game and I have stored the map data in a 2-dimensional array of size [34][10]. Originally I generated the map using a simple function to fill up the array and saved this data to a file using the following code:
ofstream myFile;
myFile.open("map.txt");
for ( int y = 0 ; y < MAP_HEIGHT ; ++y )
{
for ( int x = 0 ; x < MAP_WI...
I have a file named test.txt that is like this:
Test
Foo
Bar
But I want to put each line in a array and print the lines like this:
line1 line2 line3
But how can I do this?
...
Hi. I'm developing an application targeted for desktop systems which may have as little as 256MB RAM (Windows 2000 and up). In my application I have this large file (>256MB) which contains fixed records of about 160 bytes/each. This application has a rather lengthy process in which, over time, it will be randomly accessing about 90% of t...
Hi,
I want to create a huge dummy file say 1~2 GBs in matter of seconds.
here is what I've written in C# :
file.writeallbytes("filename",new byte[a huge number]);
and another way with indicating the status, was like following :
long FSS = din.TotalFreeSpace;
long segments = FSS / 10000;
long last_seg = FSS % 10000;
BinaryWriter br =...
Is there any way to lock a file until a browser is closed, the user leaves the current page, or their session expires?
I have a java app that reads annotations from a text file and lets a user modify or add more annotations to a pdf through the java app. Once they do, they click 'save' and the full annotation file is returned to it's or...
Hi,
I am trying to read a gunzipped file (.gz) in python and am having some trouble.
I used the gzip module to read it but the file is encoded as a utf-8 text file so eventually it reads an invalid character and crashes.
Does anyone know how to read gzip files encoded as utf-8 files? I know that there's a codecs module that can help ...
I know how to do this via streamreader and read to the end of line, but was curious if there was a fancier way of going it (for the sake of learing).
filename: blah.csv
File layout is simple:
"Some234234 ", 234
"blahblha234234 ", 2322
I want to load this into a dictionary (the second part should be a int, but I will pars...
For some reason my buffer is getting filled with jibberish, and I'm not sure why. I even checked my file with a hex editor to verify that my characters are saved in a 2 byte unicode format. I'm not sure what's wrong.
[on file open]
fseek(_file_pointer, 0, SEEK_END);
this->_length = ftell(this->_file_pointer) / sizeof(chr);
[Main]
//...
I am looking as a new file format specification and the specification says the file can be either xml based or a zip file containing an xml file and other files.
The file extension is the same in both cases. What ways could I test the file to decide if it needs decompressing or just reading?
...
Hi All,
Sorry about the lame title.
I have a project I'm working on and I would appreciate any suggestions as to how I should go about doing the IO stuff.
Ok, I have 3 text files. One file contains many many lines of text. This is the same for the other 2 files. Let's call them File1, File2 and File3.
I need to create a text file, fo...
this question is according to this topic :
creating a huge dummy file in a matter of seconds in c#
I just checked the fsutil.exe in xp/vista/seven to write a huge amount of dummy data into storage disk and it takes less time to write such a big file in comparison to programmatically way.
when I'm trying to do the same thing with the he...
I need to write to an executable file that is being executed, but I can't open it for writing. For example:
#include <stdio.h>
#include <fcntl.h>
int main(int argc, char **argv)
{
int fd = open(argv[0], O_RDWR);
if (fd == -1) perror(NULL);
return 0;
}
% uname -rs
FreeBSD 8.0-STABLE
% ./example_ETXTBSY
Text file busy
Th...
Is there currently a filesystem agnostic way to have a file in two locations on a network, change one copy, and have just the changed bits (or more likely blocks) synced to the other copy?
It would be awesome to have media files in the cloud, allow another service to read them and me to edit them with their web app, and then only have t...
Is there a way to get a C stream object (a FILE* object) that points at nothing?
I know fopen("/dev/null","w"); would work but I'm wondering if there is a better way.
Preferably that bit buckets the data at a higher level than the posix layer and that is also more portable.
...
I deployed a Ruby on Rails app to Heroku, and I realized they have a read-only file system (http://docs.heroku.com/constraints#read-only-filesystem). This means I can't cache images locally, for example. I was using a Ruby gem called "Rio" (Ruby Input/Output), and that let me save files to my /public/images directory. Are there any go...
Ok, so I'm reading a binary file into a char array I've allocated with malloc.
(btw the code here isn't the actual code, I just wrote it on the spot to demonstrate, so any mistakes here are probably not mistakes in the actual program.) This method reads at about 50million bytes per second.
main
char *buffer = (char*)malloc(file_length_...
How can I print only the current time (not the date) to a file? I need it in this format...
13:55:36
I've tried a few different ideas but they all include the date too.
...
Possible Duplicates:
Speed up File.Exists for non existing network shares
Faster DirectoryExists function?
We need to write text to a file on our network, but there may be a situation where that location does not exist and we need to write to another location instead. How do you check quickly that a network location exists? At...
Suppose I want to get several of a file's properties (owner, size, permissions, times) as returned by the lstat() system call. One way to do this in Java is to create a java.io.File object and do calls like length(), lastModified(), etc. on it. I have two problems so far:
Each one of these calls triggers a stat() call, and for my pur...
I'm attempting to shrink a file in place.
I'm replacing the contents of one file with those of another and when I'm done I want to make sure if the source file is smaller than the dest file, the dest file shrinks correctly.
(Why: because the dest file is a backup and writing to the media is very expensive, so I only write the deltas to ...