Search Results

Search found 11972 results on 479 pages for 'writing'.

Page 21/479 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • Can someone provide an example of seeking, reading, and writing a >4GB file using boost iostreams

    - by Queueless
    I have read that boost iostreams supposedly supports 64 bit access to large files semi-portable way. Their FAQ mentions 64 bit offset functions, but there is no examples on how to use them. Has anyone used this library for handling large files? A simple example of opening two files, seeking to their middles, and copying one to the other would be very helpful. Thanks.

    Read the article

  • Writing a Makefile.am to invoke googletest unit tests

    - by jmglov
    I am trying to add my first unit test to an existing Open Source project. Specifically, I added a new class, called audio_manager: src/audio/audio_manager.h src/audio/audio_manager.cc I created a src/test directory structure that mirrors the structure of the implementation files, and wrote my googletest unit tests: src/test/audio/audio_manager.cc Now, I am trying to set up my Makefile.am to compile and run the unit test: src/test/audio/Makefile.am I copied Makefile.am from: src/audio/Makefile.am Does anyone have a simple recipe for me, or is it to the cryptic automake documentation for me? :)

    Read the article

  • Error on writing data to DVD

    - by sijith
    Hi, From past 1 week i stuck on this please help me i am attaching code. bool DVDBurner::Burner() { m_hResult = CoCreateInstance(__uuidof(MsftDiscFormat2Data), NULL, CLSCTX_INPROC_SERVER, __uuidof(IDiscFormat2Data), (void**)&m_discFormatData); if (!SUCCEEDED(m_hResult)) { qDebug()<<"Unable to Initialize IDiscFormat2Data "; return false; } m_hResult = CoCreateInstance(__uuidof(MsftDiscRecorder2), NULL, CLSCTX_INPROC_SERVER, __uuidof(IDiscRecorder2), (void**)&m_discRecorder); if (FAILED(m_hResult)) { qDebug()<<"Unable to Initialize IDiscRecorder2 Data "; return false; } BSTR bstrDeviceName; HRESULT hr = S_OK; BOOL bComInitialised; UINT iCounter = 0; LONG lValue = 0; LONG iCount; bComInitialised = SUCCEEDED(CoInitializeEx(0, COINIT_MULTITHREADED)); // Create an object of IDiscMaster2 if (SUCCEEDED(hr)){ CoCreateInstance( CLSID_MsftDiscMaster2, NULL, CLSCTX_ALL, IID_PPV_ARGS(&discMaster) ); if(FAILED(hr)){ qDebug()<<"\nUnsuccessful in creating an instance of CLSID_MsftDiscMaster2.\n\nError returned: 0x%x\n"<<hr; return 0; } } /////////////////////////// Get the number of drives/////////////////////////////// if (SUCCEEDED(hr)){ hr = discMaster->get_Count(&lValue); if (SUCCEEDED(hr)){ printf("lValue %d\n\n",lValue); } } ////////////////////////// Print all the optical drives attached to the system//// if (SUCCEEDED(hr)){ for(iCount = 0; iCount < lValue; iCount++) { hr = discMaster->get_Item(iCount, &bstrDeviceName); qDebug()<<"\nUnique identifier of the disc device associated with index"<< iCount<< bstrDeviceName; } } m_hResult = m_discRecorder->InitializeDiscRecorder(bstrDeviceName); if (!SUCCEEDED(m_hResult)) { qDebug()<<"IDiscFormat2Data->InitializeDiscRecorder Failed "; return false; } LPCWSTR pszFile=L"D:\\Test\\output.txt"; ULONGLONG mediaSize = 0; mediaSize=GetSizeOnDisc(pszFile); IStream* dataStream = NULL; if (dataStream == NULL) { SHCreateStreamOnFileEx(pszFile, STGM_READ|STGM_SHARE_DENY_NONE|STGM_DELETEONRELEASE, FILE_ATTRIBUTE_NORMAL, FALSE,NULL, &dataStream); } m_hResult = m_discFormatData->put_Recorder(GetInterface()); if (!SUCCEEDED(m_hResult)) { qDebug()<<"IDiscFormat2Data->put_Recorder Failed ";return false;} char *ansistr = "DVDBurner"; int a = lstrlenA(ansistr); BSTR unicodestr = SysAllocStringLen(NULL, a); ::MultiByteToWideChar(CP_ACP, 0, ansistr, a, unicodestr, a); m_hResult = m_discFormatData->put_ClientName(unicodestr); if (FAILED(m_hResult)){qDebug()<<"Unable to put_ClientName(buf_bstr)";return false;} m_hResult = m_discFormatData->Write(dataStream); // Here i am getting error 0xc0aa0403 if (FAILED(m_hResult)){printf("Unable to m_discFormatData- >Write::::Error:0x%08x",m_hResult); return false;} discMaster->Release(); CoUninitialize(); bComInitialised = FALSE; return 0; } ULONGLONG DVDBurner::GetSizeOnDisc(LPCWSTR pszFile) { CFileStatus status; if (CFile::GetStatus(pszFile, status)) { if (status.m_size > 0) { return ((status.m_size / SECTOR_SIZE) + 1) * SECTOR_SIZE; } } return 0; }

    Read the article

  • Android: writing a file to sdcard

    - by Sumit M Asok
    I'm trying to write a file from an Http post reply to a file on the sdcard. Everything works fine until the byte array of data is retrieved. I've tried setting WRITE_EXTERNAL_STORAGE permission in the manifest and tried many different combinations of tutorials I found on the net. All I could find was using the openFileOutput("",MODE_WORLD_READABLE) method, of the activity but how my app writes file is by using a thread. Specifically, a thread is invoked from another thread when a file has to be written, so giving an activity object didn't work even though I tried it. The app has come a long way and I cannot change how the app is currently written. Please, someone help me? CODE: File file = new File(bgdmanip.savLocation); FileOutputStream filecon = null; filecon = new FileOutputStream(file); // bgdmanip.savLocation holds the whole files path byte[] myByte; myByte = Base64Coder.decode(seReply); Log.d("myBytes", String.valueOf(myByte)); bos.write(myByte); filecon.write(myByte); myvals = x * 11024; seReply is a string reply from HttpPost response. the second set of code is looped with reference to x. the file is created but remains 0 bytes

    Read the article

  • .NET and P2P - writing a P2P messenger

    - by brovar
    Hi there, Does anyone have any advice how to write such app? Or maybe knows some nice tutorial? I would like to use System.Net.PeerToPeer namespace, but everything I can find about it is MSDN which I can't read without getting mad. Or maybe using "old-school" TCP/IP would more efficient? I will appreciate every piece of advice. Every sample code I will shower with gold ;) And please, don't send me back to Google for I have searched for a long time for sth useful - maybe inaccurately but time is running out and I really need some help.

    Read the article

  • Some questions about writing on ASP.NET response stream

    - by vtortola
    Hi, I'm making tests with ASP.NET HttpHandler for download a file writting directly on the response stream, and I'm not pretty sure about the way I'm doing it. This is a example method, in the future the file could be stored in a BLOB in the database: public void GetFile(HttpResponse response) { String fileName = "example.iso"; response.ClearHeaders(); response.ClearContent(); response.ContentType = "application/octet-stream"; response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName); using (FileStream fs = new FileStream(Path.Combine(HttpContext.Current.Server.MapPath("~/App_Data"), fileName), FileMode.Open)) { Byte[] buffer = new Byte[4096]; Int32 readed = 0; while ((readed = fs.Read(buffer, 0, buffer.Length)) > 0) { response.OutputStream.Write(buffer, 0, readed); response.Flush(); } } } But, I'm not sure if this is correct or there is a better way to do it. My questions are: When I open the url with the browser, appears the "Save File" dialog... but it seems like the server has started already to push data into the stream before I click "Save", is that normal? If I remove the line"response.Flush()", when I open the url with the browser, ... I see how the web server is pushing data but the "Save File" dialog doesn't come up, (or at least not in a reasonable time fashion) why? When I open the url with a WebRequest object, I see that the HttpResponse.ContentLength is "-1", although I can read the stream and get the file. What is the meaning of -1? When is HttpResponse.ContentLength going to show the length of the response? For example, I have a method that retrieves a big xml compresed with deflate as a binary stream, but in that case... when I access it with a WebRequest, in the HttpResponse I can actually see the ContentLength with the length of the stream, why? What is the optimal length for the Byte[] array that I use as buffer for optimal performance in a web server? I've read that is between 4K and 8K... but which factors should I consider to make the correct decision. Does this method bloat the IIS or client memory usage? or is it actually buffering the transference correctly? Sorry for so many questions, I'm pretty new in web development :P Cheers.

    Read the article

  • How to overcome vc++ warning C4003 while writing common code for both gcc and vc++

    - by compbugs
    I have a code that is compiled in both gcc and vc++. The code has a common macro which is called in two scenarios. When we pass some parameters to it. When we don't want to pass any parameters to it. An example of such a code is: #define B(X) A1##X int main() { int B(123), B(); return 0; } The expect output from the pre-processing step of compilation is: int main() { int A1123, A1; return 0; } The output for both gcc and vc++ is as expected, but vc++ gives a warning: warning C4003: not enough actual parameters for macro 'B' How can I remove this warning and yet get the expected output? Thanks.

    Read the article

  • Writing a Jeweler Rakefile that adds dependencies depending on RUBY_ENGINE (ruby or jruby)

    - by Matt Zukowski
    I have a Rakefile that includes this: Jeweler::Tasks.new do |gem| # ... gem.add_dependency('json') end The gemspec that this generates builds a gem that can't be installed on jruby because the 'json' gem is native. For jruby, this would have to be: Jeweler::Tasks.new do |gem| # ... gem.add_dependency('json-jruby') end How do I conditionally add the dependency for 'json-jruby' when RUBY_ENGINE == 'java'? It seems like my only option is to manually edit the gemspec file that jeweler generates to add the RUBY_ENGINE check. But I'd rather avoid this, since it kind of defeats the purpose of using jeweler in the first place. Any ideas?

    Read the article

  • cache_money only writing to memcached on creates and updates, and seemingly never looking in the cac

    - by Shane Liebling
    I seem to be having some extremely odd cache_money interactions. When I am on the console, and I create a new instance of a class and save it I see the cache misses and cache stores on my memcached console output. Then when the create finishes I see a bunch of cache deletions. If I then try to do any kind of find for the newly created object (or any other objects for that matter) I never see any cache access. This is highly confusing. I could kind of understand if all finds never hit the cache (though that in and of itself would be an issue requiring investigation), but finds do seem to hit the cache when the object is being created (checking for associations and such). Anyone have this experience in the past at all? Any thoughts? AFAIK there isn't really much in the way of configuration options for cache_money, and it certainly doesn't seem like there are any that would be on by default and be creating these kinds of symptoms. My cache_money config is basically straight out of the docs. Any help would be greatly appreciated.

    Read the article

  • Writing to a new line of a file in Objective-C

    - by Kulpreet
    For some strange reason, the \n and \r escape sequences do not seem to be working in my code. I want to write each NSString on a new line of the file, but it just appends it the last string on one line. Here's the code: for (Entry *entry in self.entries) { NSString *path = @"/Users/me/File.txt"; NSString *string = (@"%@\r\n", [entry thisEntry]); NSFileHandle *fh = [NSFileHandle fileHandleForWritingAtPath:path]; [fh seekToEndOfFile]; [fh writeData:[string dataUsingEncoding:NSUnicodeStringEncoding]]; [fh closeFile]; } Am I doing something wrong? Forgive me as I am new to Objective-C.

    Read the article

  • Things one needs to know while writing a game engine

    - by Joe Barr
    I have been dabbling in game development as a hobby for a while now, and I cannot seam to quite get my games to sparkle at least a bit with some graphics. I have decided to write a simple test game engine that only focuses on the representation of graphics - shapes, textures and surfaces. While I have a few very simple game engines designed for my own games under my belt, I want to create a game engine that I can use to display and play with graphics. I'm going to do this in C++. Since this is my first time with a major engine, the engine in not going to focus on 3D graphics, it's going to be a mixture of isometric and 2D graphics. My previous engines have incorporated (been able to draw) or focused on simple flat (almost 2D) non impressive graphic designs and representations of: the player NPCs objects walls and surfaces textures Also, I had some basic AI and sometimes even sound. They also saved and loaded games. They didn't have a map editor or a level editor. Is this going to be a problem in the future? At this time I have to point out that some of my games didn't get finished because I was to lazy to write the few last levels. My question at this point would be: What are some things one should know if one wants write (develope) a better graphical game engine with all it's functions.

    Read the article

  • c# Unit Test: Writing to Settings in unit test does not save values in user.config

    - by HorstWalter
    I am running a c# unit test (VS 2008). Within the test I do write to the settings, which should result in saving the data to the user.config. Settings.Default.X = "History"; // X is string Settings.Default.Save(); But this simply does not create the file (I have crosschecked under "C:\Documents and Settings\HW\Local Settings\Application Data"). If I create the same stuff as a Console application, there is no problem persisting the data (same code). Is there something special I need to consider doing this in a UnitTest?

    Read the article

  • Writing preprocessor directives to get string

    - by Dave18
    Can you write preprocessor directives to return you a std::string or char*? For example: In case of integers: #define square(x) (x*x) int main() { int x = square(5); } I'm looking to do the same but with strings like a switch-case pattern. if pass 1 it should return "One" and 2 for "Two" so on..

    Read the article

  • Writing a blackjack console program in Java

    - by user337465
    Hello, I have an assignment of making a blackjack like program in a class. My first problem I am dealing with is creating an array of the cards. The professor wants an array setup with a txt file with the following format. 2 of hearts 2 of diamonds 2 of spades 2 of clubs 3 of hearts 3 of diamonds 3 of spades This goes on till face cards when it replaces the number with jack, queen, king, ace. Following the professors requirements, How would I take input from the txt file and just store the number and the hearts,diamonds,spades, and clubs. Thank you for the help

    Read the article

  • java : writing large files ?

    - by umanga
    Greetings , I get huge number of records from database and write into a file.I was wondering what the best way to write huge files. (1Gb - 10Gb). Currently I am using BufferedWriter BufferedWriter mbrWriter=new BufferedWriter(new FileWriter(memberCSV)); while(done){ //do writings } mbrWriter.close();

    Read the article

  • Writing String to Stream and reading it back does not work

    - by Binary255
    I want to write a String to a Stream (a MemoryStream in this case) and read the bytes one by one. stringAsStream = new MemoryStream(); UnicodeEncoding uniEncoding = new UnicodeEncoding(); String message = "Message"; stringAsStream.Write(uniEncoding.GetBytes(message), 0, message.Length); Console.WriteLine("This:\t\t" + (char)uniEncoding.GetBytes(message)[0]); Console.WriteLine("Differs from:\t" + (char)stringAsStream.ReadByte()); The (undesired) result I get is: This: M Differs from: ? It looks like it's not being read correctly, as the first char of "Message" is 'M', which works when getting the bytes from the UnicodeEncoding instance but not when reading them back from the stream. What am I doing wrong? The bigger picture: I have an algorithm which will work on the bytes of a Stream, I'd like to be as general as possible and work with any Stream. I'd like to convert an ASCII-String into a MemoryStream, or maybe use another method to be able to work on the String as a Stream. The algorithm in question will work on the bytes of the Stream.

    Read the article

  • Writing text on icon of Menu in Android?

    - by sunil
    Hi, Can we set Title for a Menu Item in Android if it has an icon from drawable? I have a icon for a Menu Item and if I set the icon then the title that is set for that Menu item is not visible. Is this possible or not? Hope to get a reply soon. Regards Sunil

    Read the article

  • Writing a regex in Latex

    - by Harm De Weirdt
    Hello everyone. In a Latex Report I am making I have to write a regex. There is only one in the whole report, so I don't really want to use packages and so on. This is the regex I am talking about: ^\"((\w|\s)+)\"$ I came up with this for Latex: \grave{ }\backslash\"'((\backslash w\| \backslash s)+)\backslash \"' \backslash \$ This gives me like 10 errors, and I can't really see what is wrong. Okay, it looks pretty bad but all the commands should work.. Thanks in advance, Harm

    Read the article

  • Writing JSON with XSLT

    - by JP
    Hi, I'm trying to write XSLT to transform a specific web page to JSON. The following code demonstrates how Ruby would do this conversion, but the XSLT doesn't generate valid JSON (there's one too many commas inside the array) - anyone know how to write XSLT to generate valid JSON? require 'rubygems' require 'nokogiri' require 'open-uri' doc = Nokogiri::HTML(open('http://bbc.co.uk/radio1/playlist')) xslt = Nokogiri::XSLT(DATA.read) puts out = xslt.transform(doc) # Now follows the XSLT __END__ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"> <xsl:output method="text" encoding="UTF-8" media-type="text/plain"/> <xsl:template match="/"> [ <xsl:for-each select="//*[@id='playlist_a']//div[@class='artists_and_songs']//ul[@class='clearme']"> {'artist':'<xsl:value-of select="li[@class='artist']" />','track':'<xsl:value-of select="li[@class='song']" />'}, </xsl:for-each> ] </xsl:template> </xsl:stylesheet>

    Read the article

  • __spin_lock while writing the bytes in NSOutputStream

    - by Mohammed Sadiq
    HI all, I have a issue that when I try to write some bytes in the outputstream, I am getting the bad access. The code is as follows : int writtenBytes = [_os write:[packetInBytes bytes] maxLength:lengthOfPacket]; where the "packetInBytes" points to NSData and "lengthOfPacket" corresponds to the data length, and _os represents the NSOutputStream. The call stack from the debugger is as follows : 0 0xffff0269 in __spin_lock 1 0x302a6098 in CFSocketDisableCallBacks 2 0x003b46d0 in SocketStream::write 3 0x302402c3 in CFWriteStreamWrite 4 0x0001b423 in -[Writer write:] at Writer.m:96 5 0x0001b5ef in -[Writer run] at Writer.m:111 6 0x3050a79d in -[NSThread main] 7 0x3050a338 in NSThread__main 8 0x91a27fe1 in _pthread_start 9 0x91a27e66 in thread_start** I am not getting this issue always. I get this issue execute my code for some 5 or more times ... I have checked all the params that i pass to the write function have its values and not nil. Any help would be greatly appreciated Best Regards, MOhammed Sadiq.

    Read the article

  • Writing to EEPROM on PIC

    - by JB
    Are there any PIC microcontroller programmers here? I'm learning some PIC microcontroller programming using a pickit2 and the 16F690 chip that came with it. I'm working through trying out the various facilities at the moment. I can sucessfully read a byte from the EEPROM in code if I set the EEPROM vaklue in MPLAB but I don't seem to be able to modify the value using the PIC itsself. Simply nothing happens and I don't read back the modified value, I always get the original which implies to me that the write isn't working? This is my code for that section, am I missing something? I know I'm doing a lot of unnecessary bank switches, I added most of them to ensure that being on the wrong bank wasn't the issue. ; ------------------------------------------------------ ; Now SET the EEPROM location ZERO to 0x08 ; ------------------------------------------------------ BANKSEL EEADR CLRF EEADR ; Set EE Address to zero BANKSEL EEDAT MOVLW 0x08 ; Store the value 0x08 in the EEPROM MOVWF EEDAT BANKSEL EECON1 BSF EECON1, WREN ; Enable writes to the EEPROM BANKSEL EECON2 MOVLW 0x55 ; Do the thing we have to do so MOVWF EECON2 ; that writes can work MOVLW 0xAA MOVWF EECON2 BANKSEL EECON1 BSF EECON1, WR ; And finally perform the write WAIT BTFSC EECON1, WR ; Wait for write to finish GOTO WAIT BANKSEL PORTC ; Just to make sure we are on the right bank

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >