Search Results

Search found 5919 results on 237 pages for 'io priority'.

Page 39/237 | < Previous Page | 35 36 37 38 39 40 41 42 43 44 45 46  | Next Page >

  • writing structs and classes to disk

    - by Phenom
    The following function writes a struct to a file. int btwrite(short rrn, BTPAGE *page_ptr) { long addr; addr = (long) rrn * (long) PAGESIZE + HEADERSIZE; lseek(btfd, addr, 0); return (write(btfd, page_ptr, PAGESIZE)); } The following is the struct. typedef struct { short keycount; /* number of keys in page */ int key[MAXKEYS]; /* the actual keys */ int value[MAXKEYS]; /* the actual values */ short child[MAXKEYS+1]; /* ptrs to rrns of descendants */ } BTPAGE; What would happen if I changed the struct to a class, would it still work the same? If I added class functions, would the size it takes up on disk increase?

    Read the article

  • Python to extract data from a file

    - by user297003
    Hi, I am new to python. I am trying to extract the text between that has specific text file: ---- data1 data1 data1 extractme ---- data2 data2 data2 ---- data3 data3 extractme ---- and then dump it to text file so that ---- data1 data1 data1 extractme --- data3 data3 extractme --- Thanks for the help.

    Read the article

  • Write file in sub-directory in Android

    - by Davide Vosti
    I'm trying to save a file in a subdirectory in Android 1.5. I can successfully create a directory using _context.GetFileStreamPath("foo").mkdir(); (_context is the Activity where I start the execution of saving the file) but then if I try to create a file in foo/ by _context.GetFileStreamPath("foo/bar.txt"); I get a exception saying I can't have directory separator in a file name ("/"). I'm missing something of working with files in Android... I thought I could use the standard Java classes but they don't seem to work... I searched the Android documentation but I couldn't fine example and google is not helping me too... I'm asking the wrong question (to google)... Can you help me out with this? Thank you!

    Read the article

  • Detecting metadata-only read requests in windows filesystem

    - by HyLian
    Hello, I'm developing a kind of filesystem driver. All of read requests that windows makes to my filesystem goes by the driver implementation. I would like to distinguish between "normal" read requests and those who want to get only the metadata from the file. ( Windows reads first 4K of the file and then stop reading ). Does Windows mark this metadata reads in some way? It would be very useful in order to treat that two kind of operations in a different way. In a typical CreateFile call, we have AccessMode, ShareMode, CreationDisposition and FlagsAndAttributes parameters ( being DWORD ), i'm not sure if it's possible to extract some clue of the operation requested. Thanks for reading :)

    Read the article

  • Can you call Directory.GetFiles() with multiple filters?

    - by Jason Z
    I am trying to use the Directory.GetFiles() method to retrieve a list of files of multiple types, such as mp3's and jpg's. I have tried both of the following with no luck: Directory.GetFiles("C:\\path", "*.mp3|*.jpg", SearchOption.AllDirectories); Directory.GetFiles("C:\\path", "*.mp3;*.jpg", SearchOption.AllDirectories); Is there a way to do this in one call?

    Read the article

  • How to pass a file (read from Java) most effectively to a native method?

    - by soc
    Hi, I have approx. 30000 files (1MB each) which I want to put into a native method, which requires just an byte array and the size of it as arguments. I looked through some examples and benchmarks (like http://nadeausoftware.com/articles/2008/02/java_tip_how_read_files_quickly) but all of them do some other fancy things. Basically I don't care about the contents of the file, I don't want to access something in that file or the byte array or do anything else with it. I just want to put a file into a native method which accepts an byte array as fast as possible. At the moment I'm using RandomAccessFile, but that's horribly slow (10MB/s). Is there anything like byte[] readTheWholeFile(File file){ ... } which I could put into native void fancyCMethod(readTheWholeFile(myFile), myFile.length()) What would you suggest?

    Read the article

  • Read a file to multiple array byte[]

    - by hankol
    I have an encryption algorithm (AES) that accepts file converted to array byte and encrypt it. Since I am going to process a very big size files, the JVM may go out of memory. I am planing to read the files in multiple array byte. each containing some part of the file. Then I teratively feed the algorithm. Finally merge them to produce encrypted file. So my question is: there any way to read a file part by part to multiple array byte? I thought I can use the following to read the file to array byte: IOUtils.toByteArray(InputStream input). And then split the array into multiple bytes using: Arrays.copyOfRange(). But I am afraid that the first code that reads file to byte will make the JVM to go out of memory. any suggestion please ? thanks

    Read the article

  • How to replace same text in a text file

    - by user1688220
    i created a c# windows login form and i am saving username or password to a text file but every time i use same username or password that i have saved before it takes new place in that text file. But What i want is to replace the same username or password that is already saved in that text file. this is my code: private void button1_Click(object sender, EventArgs e) { try { FileStream fs = new FileStream("data.txt", FileMode.Append, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); sw.Write("Email ID: "); sw.WriteLine(textBox1.Text); sw.Write("Password: "); sw.Write(textBox2.Text); sw.WriteLine(); sw.WriteLine(); sw.Flush(); sw.Close(); fs.Close(); } catch (Exception) { MessageBox.Show("Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } MessageBox.Show("DONE", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox1.Clear(); textBox2.Clear(); }

    Read the article

  • What influences running time of reading a bunch of images?

    - by remi
    I have a program where I read a handful of tiny images (50000 images of size 32x32). I read them using OpenCV imread function, in a program like this: std::vector<std::string> imageList; // is initialized with full path to the 50K images for(string s : imageList) { cv::Mat m = cv::imread(s); } Sometimes, it will read the images in a few seconds. Sometimes, it takes a few minutes to do so. I run this program in GDB, with a breakpoint further away than the loop for reading images so it's not because I'm stuck in a breakpoint. The same "erratic" behaviour happens when I run the program out of GDB. The same "erratic" behaviour happens with program compiled with/without optimisation The same "erratic" behaviour happens while I have or not other programs running in background The images are always at the same place in the hard drive of my machine. I run the program on a Linux Suse distrib, compiled with gcc. So I am wondering what could affect the time of reading the images that much?

    Read the article

  • Scan file contents into an array of a structure.

    - by ZaZu
    Hello, I have a structure in my program that contains a particular array. I want to scan a random file with numbers and put the contents into that array. This is my code : ( NOTE : This is a sample from a bigger program, so I need the structure and arrays as declared ) The contents of the file are basically : 5 4 3 2 5 3 4 2 #include<stdio.h> #define first 500 #define sec 500 struct trial{ int f; int r; float what[first][sec]; }; int trialtest(trial *test); main(){ trial test; trialtest(&test); } int trialtest(trial *test){ int z,x,i; FILE *fin; fin=fopen("randomfile.txt","r"); for(i=0;i<5;i++){ fscanf(fin,"%5.2f\t",(*test).what[z][x]); } fclose(fin); return 0; } But the problem is, whenever this I run this code, I get this error : (25) : warning 508 - Data of type 'double' supplied where a pointer is required I tried adding do{ for(i=0;i<5;i++){ q=fscanf(fin,"%5.2f\t",(*test).what[z][x]); } }while(q!=EOF); But that didnt work either, it gives the same error. Does anyone have a solution to this problem ?

    Read the article

  • Generic file container for quick read of data

    - by DreamCodeR
    Since there are some major privacy issues with alot of social networking sites I am trying to think about alternatives. One is to let the user keep all the information stored in some kind of file container. Now, I haven't found a single type of container that can hold "generic" information. Only for audio/video. What I want is a container that can be read by PHP with some kind of index file that lists up the users pictures in a image/ directory in the container, FOAF files (or some alternative XML-file describing users information and friends, etc.). My thoughts was to let the user keep all their information and data stored in a container that can be imported/exported and deleted from my server (the prototype social networking site I am trying to create), and then uploaded to another site that might use the same format (not that I think that will ever happen, but the user still keeps all their pictures, data, comments, messages, etc). The only thing I have come up with yet is to create a tar archive with the Archive_tar library which extracts and creates Tar-archives with an index-file describing which files are holding the messages (there might be several so each file won't be so large), what pictures are in the image/ folder and what are their names and what comments they have gotten etc. Maybe also the permissions for viewing each type of content. Does there exist any generic file format of a container that I can use to keep all this information in one file with a tree-like index file? Or must i try and create something like this myself?

    Read the article

  • Why are some programs writing on stderr instead of stdout their output?

    - by Zagorax
    I've recently added to my .bashrc file an ssh-add command. I found that ssh-add $HOME/.ssh/id_rsa_github > /dev/null results on a message "identity added and something else" every time I open a shell. While ssh-add $HOME/.ssh/id_rsa_github > /dev/null 2>&1 did the trick and my shell is now 'clean'. Reading on internet, I found that other command do it, (for example time). Could you please explain why it's done?

    Read the article

  • Enter custom file name to be read ?

    - by ZaZu
    Hello, I want to allow users to type the name of any .txt file to be read/written. This is my code : printf("Enter .txt file name\n"); scanf("%s",&fname); FILE *inputf; inputf=fopen(&fname,"w"); Problem is this method does not work (having &fname) as a parameter. I can imagine its because C needs "filename.txt" for it work ... even if I enter for example : "custom.txt", the program returns an error of "Storage block not big enough for this operation" What is the correct method to accomplish this ? Im using C and im pretty much using basic commands .. (not too advanced) Thanks alot !!!

    Read the article

  • Writing at the end of file

    - by user342534
    Hi, I'm working on a system that requires high file I/O performance (with C#). Basically, I'm filling up large files (~100MB) from the start of the file until the end of the file. Every ~5 seconds I'm adding ~5MB to the file (sequentially from the start of the file), on every bulk I'm flushing the stream. Every few minutes I need to update a structure which I write at the end of the file (some kind of metadata). When flushing each one of the bulks I have no performance issue. However, when updating the metadata at the end of the file I get really low performance. My guess is that when creating the file (which also should be done extra fast), the file doesn't really allocates the entire 100MB on the disk and when I flush the metadata it must allocates all space until the end of file. Guys/Girls, any Idea how I can overcome this problem? Thanks a lot!

    Read the article

  • which one consume less resources? opening text file or make an sql query,both a thousand times ?

    - by imin
    hi I've a php website which displays recipes www.trymasak.my, to be exact. The recipes being displayed at the index page is updated about once a day. To get the latest recipes, I just use a mysql query which is something like "select recipe_name, page_views, image from table order by last_updated". So if I got 10000 visitors a day, obviously the query would be made 10000 times a day. A friend told me a better way (in terms of reducing server load) is when I update the recipes, I just put in the latest recipe details (names,images etc) into a text file, and make my page instead of querying a same query for 10,000 times, just get the data from the text file. Is his suggestion really better? If yes, which is the best php command should I use to open, read and close the text file? thanks

    Read the article

  • Perl, redirect stdout to file

    - by Mike
    I'm looking for an example of redirecting stdout to a file using Perl. I'm doing a fairly straightforward fork/exec tool, and I want to redirect the child's output to a file instead of the parents stdout. Is there an equivilant of dup2() I should use? I can't seem to find it

    Read the article

  • How can I modify the application file of an application that is currently running (on Linux)?

    - by Hach-Que
    I have an application running called AppFS. This application has an ext2 filesystem just attached to the end of the file (it's positioned so that the application binary exists in a 1MB spacing area, followed by the ext2 data). Now I've got FUSE embedded in the program and I've managed to extract the filesystem out of the application data into a temporary file so that FUSE can mount / use it. The problem I have now is writing the temporary file back into the application file. I get "Text file busy" presumably because the application has locked itself and won't let writes occur. Is there a way I can force the file to become unlocked so I can write data to it? (It's important to note that I'm not changing the application binary area - just rewriting the ext2 component.) It needs to be unlocked without requiring root permissions (unlocked by the same user who started the application).

    Read the article

  • Parsing C# Script into Java

    - by pantaryl
    I'm looking for a way to easily read in a C# file and place it into a Java Object for database storage (storing the class name, functions, variables, etc). I'm making a Hierarchical State Machine AI Building Tool for a game I'm creating and need to be able to import an existing C# file and store it in a database for retrieval in the future. Does anyone know of any preexisting libraries for parsing C# files? Something similar to JavaParser? Thanks everyone! EDIT: This needs to be part of my Java Project. I'll be loading in the C# files through my Java Application and saving it into my db4o database.

    Read the article

  • Naming a file downloaded from url in iPhone

    - by hgpc
    I would like to save a file downloaded from the internet in iPhone. Can I use the url as the file name? If not, what transformation should I apply to the url to obtain a valid file name? I need to find the local copy of the file later using its url.

    Read the article

  • FileInput Help/Advice

    - by user559142
    I have a fileinput class. It has a string parameter in the constructor to load the filename supplied. However it just exits if the file doesn't exist. I would like it to output a message if the file doesn't exist - but not sure how.... Here is the class: public class FileInput extends Input { /** * Construct <code>FileInput</code> object given a file name. */ public FileInput(final String fileName) { try { scanner = new Scanner(new FileInputStream(fileName)); } catch (FileNotFoundException e) { System.err.println("File " + fileName + " could not be found."); System.exit(1); } } /** * Construct <code>FileInput</code> object given a file name. */ public FileInput(final FileInputStream fileStream) { super(fileStream); } } And its implementation: private void loadFamilyTree() { out.print("Enter file name: "); String fileName = in.nextLine(); FileInput input = new FileInput(fileName); family.load(input); input.close(); }

    Read the article

  • Read file structure into an array, but only specific files.

    - by dmackerman
    I have a directory structure that looks like this: /expandables - folder - folder - folder - folder - BannerInfo.txt - index.html Each one of the folder has the same exact stucture. One file named BannerInfo.txt and index.html. There are about 250 of these folders if that matters. I want to loop through these folders and store each of the index.html files into an array. Inside of the index.html file is just some simple HTML and Javascript of which I want to read into a string to be displayed later on. I'm struggling with how to filter out only the index.html file from the individual folders. The purpose of this is because I want to randomly select an index.html file and put the contents into a textarea. I thought I could do a simple array_rand() on the returned array and spit out the string. Any ideas?

    Read the article

  • Java: GatheringByteChannel advantages?

    - by Jason S
    I'm wondering when the GatheringByteChannel's write methods (taking in an array of ByteBuffers) have advantages over the "regular" WritableByteChannel write methods. I tried a test where I could use the regular vs. the gathering write method on a FileChannel, with approx 400KB/sec total in ByteBuffers of between 23-27 bytes in length in both cases. Gathering writes used an array of 64. The regular method used up approx 12% of my CPU, and the gathering method used up approx 16% of my CPU (worse than the regular method!) This tells me it's NOT useful to use gathering writes on a FileChannel around this range of operating parameters. Why would this be the case, and when would you ever use GatheringByteChannel? (on network I/O?) Relevant differences here: public void log(Queue<Packet> packets) throws IOException { if (this.gather) { int Nbuf = 64; ByteBuffer[] bbufs = new ByteBuffer[Nbuf]; int i = 0; Packet p; while ((p = packets.poll()) != null) { bbufs[i++] = p.getBuffer(); if (i == Nbuf) { this.fc.write(bbufs); i = 0; } } if (i > 0) { this.fc.write(bbufs, 0, i); } } else { Packet p; while ((p = packets.poll()) != null) { this.fc.write(p.getBuffer()); } } }

    Read the article

  • How do I read and write to a file using threads in java?

    - by WarmWaffles
    I'm writing an application where I need to read blocks in from a single file, each block is roughly 512 bytes. I am also needing to write blocks simultaneously. One of the ideas I had was BlockReader implements Runnable and BlockWriter implements Runnable and BlockManager manages both the reader and writer. The problem that I am seeing with most examples that I have found was locking problems and potential deadlock situations. Any ideas how to implement this?

    Read the article

< Previous Page | 35 36 37 38 39 40 41 42 43 44 45 46  | Next Page >