Search Results

Search found 24117 results on 965 pages for 'write'.

Page 25/965 | < Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >

  • Download and write .tar.gz files without corruption.

    - by arbales
    I've tried numerous ways of downloading files, specifically .zip and .tar.gz, with Ruby and write them to the disk. I've found that the file appears to be the same as the reference (in size), but the archives refuse to extract. What I'm attempting now is: Thanks! def download_request(url, filePath:path, progressIndicator:progressBar) file = File.open(path, "w+") begin Net::HTTP.get_response URI.parse(url) do |response| if response['Location']!=nil puts 'Direct to: ' + response['Location'] return download_request(response['Location'], filePath:path, progressIndicator:progressBar) end # some stuff response.read_body do |segment| file.write(segment) # some progress stuff. end end ensure file.close end end download_request("http://github.com/jashkenas/coffee-script/tarball/master", filePath:"tarball.tar.gz", progressIndicator:nil)

    Read the article

  • Correct way to write /* and */

    - by billpg
    Hi everyone. I'd like to know, please, the correct way to write the symbols that the C family of languages use to begin and end comments. Before you all respond "a slash followed by an asterisk", I mean what's the correct way to write them on paper. (IE, How many points should the asterisk have? What angle should the slash be? etc) Everything I need so I can sit down and draw correct comment start and end symbols. Please note, I'm looking for the correct standard way. If there is no industry standard, please respond with "there is no standard" and I will accept that answer.

    Read the article

  • How to write data by dynamic parameter name

    - by Maxim Welikobratov
    I need to be able to write data to datastore of google-app-engine for some known entity. But I don't want write assignment code for each parameter of the entity. I meen, I don't want do like this val_1 = self.request.get('prop_1') val_2 = self.request.get('prop_2') ... val_N = self.request.get('prop_N') item.prop_1 = val_1 item.prop_2 = val_2 ... item.prop_N = val_N item.put() instead, I want to do something like this args = self.request.arguments() for prop_name in args: item.set(prop_name, self.request.get(prop_name)) item.put() dose anybody know how to do this trick?

    Read the article

  • data path (travel) of tcp data from "write" syscall downto I/O registers programming

    - by osgx
    Hello Is there a good overview of tcp data path in Linux (2.6, not 2.4 if the path actually differ)? Where is a packet on different stages of tcp/ip stack handling? How packet is packed to tcp segment, then ip packet. How it is transmitted to network card? (with series of I/O regs write and DMA?) Is it transmitted to network card in the "write" syscall handler (with some deep callstack) or is it transmitted at some other moment?

    Read the article

  • Haskell Write Computation result to file

    - by peterwkc
    Hello to all, i have function which create a tuple after computation but i would like to write it to file. I know how to write file using writeFile but did not know how to combine computation and monads IO together in the type signature This is my code. invest :: ([Char]->Int->Int->([Char], Int) ) -> [Char]->Int->Int->([Char], Int) invest myinvest x y = myinvest x y myinvest :: [Char]->Int->Int->([Char], Int) myinvest w x y | y > 0 = (w, x + y) | otherwise = error "Invest amount must greater than zero" where I have a function which computes the maximum value from list but i want to these function receive input from file then perform the computation of maximum value. maximuminvest :: (Ord a) => [a] -> a maximuminvest [] = error "Empty Invest Amount List" maximuminvest [x] = x maximuminvest (x:xs) | x > maxTail = x | otherwise = maxTail where maxTail = maximuminvest xs Please help. Thanks.

    Read the article

  • Prevent unauthorised write access to a part of filesystem or partition

    - by gaurav
    Hello all I have some very important system files which I want to protect from accidental deletion even by root user. I can create a new partition for that and mount it with readonly access but the problem is that I want my application which handles those system files to have write access to that part and be able to modify them. Is that possible using VFS? As VFS handles access to the files I could have a module inserted in the VFS layer which can see if there is a write access to that part then see the authorization and allow it or otherwise reject it. If not please provide me suggestions regarding how can such a system be implemented what would I need in that case. If there exists a system like this please suggest about them also. I am using linux and want to implement this in C, I think it would be possible in C only. Edit: There are such kind of programs implemented in windows which can restrict access to administrator even, to some important folders, would that be possible in linux?

    Read the article

  • cannot read but can write on serial port through Android Emulator

    - by Aad
    I am working on a program that is communicating with serial port over USB through Android emulator. emulator -qemu -serial /dev/ttyUSB0 The emulator is able to open the port and write into it. However, read is not happening. The program has a timeout for read maintained by a timer. The read happens in a separate 'read' thread. The main thread has a socketpair fd pair to signal the read-thread that the serial port is closed post timeout. In the read-thread, polling happens(poll() function call) over the 2 file-descriptors: one is serial port fd, the other is one of the socketpair. The board that I have connected to works fine with sending commands over 'cutecom' The poll never succeeds for serial port. However, poll succeeds for 'socketpair'ed fd and the thread ends on a close-signal sent from main-thread post timeout. Ouestions: Are there any special settings for read as even loop-back fails Are there differences between settings for read and write on a serial port?

    Read the article

  • write image file larger than 4096

    - by ntan
    Hi, *************EDIT********** i am using ODBC and found that can not read more than 4096 for a field Any suggestions *************EDIT************ i am reading an image from db $image=$row["image-contents"]; Now try to write the file to disk $image_name="test.jpg"; $file = fopen( "images/".$image_name, "w" ); fwrite( $file, $image); fclose( $file ); The problem is that the file created is only 4096 bytes and the image file is corrupt because $image is larger than 4096. I now that fwrite use blocks for write but i dont know how do it. Help plz!

    Read the article

  • Learning to write organized and modular programs (C++)

    - by Peter
    Hi All, I'm a computer science student, and I'm just starting to write relatively larger programs for my coursework (between 750 - 1500 lines). Up until now, it's been possible to get by with any reasonable level of modularization and object oriented design. However, now that I'm writing more complex code for my assignments I'd like to learn to write better code. Can anyone point me in the direction of some resources for learning about what sort of things to look for when designing your program's architecture so that you can make it as modularized as possible? Thank you for any help. Best, Peter

    Read the article

  • Need a push in the write direction, to write my first functional test in Rails?

    - by Jason
    Hi, I've read quiet a bit of documentation over the last few days about testing in Rails, I'm sitting down to write my first real test and not 100% sure how to tie what I have learned together to achieve the following functional test (testing a controller) I need to send a GET request to a URL and pass 3 parameters (simple web-service), if the functionality works the keyword "true" is simply returned, otherwise the keyword "false" is returned - its in only value returned & not contained in any , or other tags. The test should assert that if "true" is returned the test is successful. This is probably very simple so apologies for such a non-challenging question. If anyone could point me in the write direction on how I can get started, particularly how I can test the response, I'd be very grateful! Thanks!

    Read the article

  • Write PEM encoded certificate in file - java

    - by user1349407
    Good day. I recently create X.509 certificate by using bouncy castle API. I need to save the certificate result rather than display the result. I tried to use FileOutputStream, but it does not work. regards the result is like follows -----BEGIN CERTIFICATE----- MIICeTCCAeKgAwIBAgIGATs8OWsXMA0GCSqGSIb3DQEBCwUAMBsxGTAXBgNVBAMT... -----END CERTIFICATE----- The code is belows import java.io.FileOutputStream; //example of a basic CA public class PKCS10CertCreateExample { public static X509Certificate[] buildChain() throws Exception { //create the certification request KeyPair pair = chapter7.Utils.generateRSAKeyPair(); PKCS10CertificationRequest request = PKCS10ExtensionExample.generateRequest(pair); //create a root certificate KeyPair rootPair=chapter7.Utils.generateRSAKeyPair(); X509Certificate rootCert = X509V1CreateExample.generateV1Certificate (rootPair); //validate the certification request if(!request.verify("BC")) { System.out.println("request failed to verify!"); System.exit(1); } //create the certificate using the information in the request X509V3CertificateGenerator certGen = new X509V3CertificateGenerator(); certGen.setSerialNumber(BigInteger.valueOf(System.currentTimeMillis())); certGen.setIssuerDN(rootCert.getSubjectX500Principal()); certGen.setNotBefore(new Date(System.currentTimeMillis())); certGen.setNotAfter(new Date(System.currentTimeMillis()+50000)); certGen.setSubjectDN(request.getCertificationRequestInfo().getSubject()); certGen.setPublicKey(request.getPublicKey("BC")); certGen.setSignatureAlgorithm("SHA256WithRSAEncryption"); certGen.addExtension(X509Extensions.AuthorityKeyIdentifier, false, new AuthorityKeyIdentifierStructure(rootCert)); certGen.addExtension(X509Extensions.SubjectKeyIdentifier, false, new SubjectKeyIdentifierStructure(request.getPublicKey("BC"))); certGen.addExtension(X509Extensions.BasicConstraints, true, new BasicConstraints(false)); //certGen.addExtension(X509Extensions.KeyUsage, true, new BasicConstraints(false)); certGen.addExtension(X509Extensions.KeyUsage, true, new KeyUsage(KeyUsage.digitalSignature | KeyUsage.keyEncipherment)); certGen.addExtension(X509Extensions.ExtendedKeyUsage, true, new ExtendedKeyUsage(KeyPurposeId.id_kp_serverAuth)); //extract the extension request attribute ASN1Set attributes = request.getCertificationRequestInfo().getAttributes(); for(int i=0;i!=attributes.size();i++) { Attribute attr = Attribute.getInstance(attributes.getObjectAt(i)); //process extension request if(attr.getAttrType().equals(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest)) { X509Extensions extensions = X509Extensions.getInstance(attr.getAttrValues().getObjectAt(0)); Enumeration<?> e = extensions.oids(); while(e.hasMoreElements()) { DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement(); X509Extension ext = extensions.getExtension(oid); certGen.addExtension(oid, ext.isCritical(), ext.getValue().getOctets()); } } } X509Certificate issuedCert = certGen.generateX509Certificate(rootPair.getPrivate()); return new X509Certificate[]{issuedCert, rootCert}; } public static void main(String[] args) throws Exception { X509Certificate[] chain = buildChain(); PEMWriter pemWrt = new PEMWriter(new OutputStreamWriter(System.out)); pemWrt.writeObject(chain[0]); //pemWrt.writeObject(chain[1]); pemWrt.close(); //write it out //FileOutputStream fOut = new FileOutputStream("pkcs10req.req"); //fOut.write(chain[0].toString()); //fOut.write() //System.out.println(chain[0].toString()); //fOut.close(); } }

    Read the article

  • Need a push in the right direction, to write my first functional test in Rails

    - by Jason
    I've read quiet a bit of documentation over the last few days about testing in Rails, I'm sitting down to write my first real test and not 100% sure how to tie what I have learned together to achieve the following functional test (testing a controller) I need to send a GET request to a URL and pass 3 parameters (simple web-service), if the functionality works the keyword true is simply returned, otherwise the keyword false is returned - its in only value returned & not contained in any <div>, <span> or other tags. The test should assert that if "true" is returned the test is successful. This is probably very simple so apologies for such a non-challenging question. If anyone could point me in the write direction on how I can get started, particularly how I can test the response, I'd be very grateful!

    Read the article

  • Write to a binary file?

    - by rick irby
    Here is data structure w/ variables: struct Part_record { char id_no[3]; int qoh; string desc; double price: }; --- (Using "cin" to input data) --- Part_record null_part = {" ", 0," ",0.0}; --- --- file.seekg( -(long)sizeof(Part_record), ios::cur); file.write( ( char *)&part, sizeof(Part_record) ); The three variables, qoh, Id_no & price, write out correctly, but the "desc" variable is not right. Do I need to initialize Part_record some other way? It should be 20 characters in length. If you have enough info here, pls share your advice,thanks.

    Read the article

  • write() in sys/uio.h returns -1

    - by fredrik
    I'm using Ubuntu Server 9.10 AMD Phenom 2 cpu g++ (Ubuntu 4.4.1-4ubuntu9) 4.4.1 trying to run the application pftp-shit v 1.11. The following code in tcp.cc is executed successfully: int outfile_fd = open(name, O_CREAT | O_TRUNC | O_RDWR | O_BINARY)) which returns a file descriptor int (in my case 6) - name is a char array containing a valid path to my file which successfully i created. and successfully running: fchmod(outfile_fd, S_IRUSR | S_IWUSR); and access(name, W_OK) The issue occurs during running the function (from sys/uio.h) write(outfile_fd, this-control_buffer, read_length) which returns -1. -1 is of returned if nothing was written and otherwise a non-negative integer is returned which is equal to the number of bytes written. Anyone having a clue how I can get the write function to work?

    Read the article

  • Write to pipe deadlocking program

    - by avs3323
    Hi, I am having a problem in my program that uses pipes. What I am doing is using pipes along with fork/exec to send data to another process What I have is something like this: //pipes are created up here if(fork() == 0) //child process { ... execlp(...); } else { ... fprintf(stderr, "Writing to pipe now\n"); write(pipe, buffer, BUFFER_SIZE); fprintf(stderr, "Wrote to pipe!"); ... } This works fine for most messages, but when the message is very large, the write into the pipe deadlocks. I think the pipe might be full, but I do not know how to clear it. I tried using fsync but that didn't work. Can anyone help me?

    Read the article

  • Write data into .txt file created by CFileDialog, in C++

    - by younevertell
    I wanna Write data into .txt file created by CFileDialog, in C++. The problem I am facing is that below codes doesn't work, although there is no build error. The .txt file created by CFileDialog can not be found for some reason. What's wrong the code? what's the efficient way to Write data into .txt file created by CFileDialog, in C++? Thanks CFileDialog dlg(FALSE, NULL, NULL, OFN_OVERWRITEPROMPT, _T("My Data File (*.txt)|*.txt||")); if(dlg.DoModal() != IDOK) return; CString filename = dlg.GetPathName(); ofstream outfile (filename); int mydata = 10; outfile << "my data:" << mydata << endl; outfile.close();

    Read the article

  • Java Synchronized Write Block

    - by ikurtz
    im new to java and i have a question regarding Synchronized. i have the following code for writing to network (simple implementation for now): public void networkSendData(byte[] data){ try { out.write(data); out.flush(); } catch (IOException e) { } } i was wondering if there is a need for block level Synchronized here as im am writing the whole data at once. or is there a chance for race condition? i ask because the data to write is coming for multiple sources. thank you.

    Read the article

  • Isolating read and write in multithreaded

    - by the_lotus
    Hi In a multithreaded application. I have a bunch of function that loop through a collection to read the information. I also have a bunch of function that modifies that same collection. I’m looking for a way to isolate all the read and the write together. I don’t want a write to be done while a read is in progress. I was thinking of using SyncLock on the collection object but this will block multiple read trying to work in parallel.

    Read the article

< Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >