Visualizzazione dei risultati da 1 a 6 su 6
  1. #1

    [C++] Sovrascrivere file

    Salve,

    ho un file dove i primi 44 bytes sono riempiti con degli 0x00 poi ho dei dati binari. Nei primi 44 bytes devo poi in seguito aggiungere dei meta dati.

    quale procedura devo seguire? aprire in append e fare seek fino all'inizio del file o c'è un'altro modo?

    grazie
    Alla batteria dai retta ballA

  2. #2
    Utente di HTML.it L'avatar di shodan
    Registrato dal
    Jun 2001
    Messaggi
    2,381
    Il primo che hai detto (aggiungendo il binary mode).
    This code and information is provided "as is" without warranty of any kind, either expressed
    or implied, including but not limited to the implied warranties of merchantability and/or
    fitness for a particular purpose.

  3. #3
    Ok, l'unico problema è che devo scrivere l'header RIFF di un file WAVE. Quindi dovrei usare la mmioOpen(); ma non so se con questa funzione posso aprire in append (binary) e eventualmente fare seek() !!!

    grazie
    Alla batteria dai retta ballA

  4. #4
    Utente di HTML.it L'avatar di shodan
    Registrato dal
    Jun 2001
    Messaggi
    2,381
    Puoi aprire il file anche con gli stream del C++, i FILE del C, le Api Windows.
    Un file è un file anche per loro.
    This code and information is provided "as is" without warranty of any kind, either expressed
    or implied, including but not limited to the implied warranties of merchantability and/or
    fitness for a particular purpose.

  5. #5
    ok, ma ad esempio se faccio:

    codice:
    std::ofstream hfile;
    hfile.open(file, std::ios::out|std::ios::binary);
    
    //step 1 create riff chunk
    mmckinfo.fccType = mmioFOURCC('W','A','V','E');
    mmioCreateChunk(hfile, &mmckinfo, MMIO_CREATERIFF);
    il programma va in errore: error C2664: 'mmioCreateChunk' : cannot convert parameter 1 from 'std:fstream' to 'HMMIO'
    Alla batteria dai retta ballA

  6. #6
    cooolpa mia! basta escludere il flag MMIO_CREATE e il file non verrà truncato a 0 bytes, inoltre con mmioSeek mio sistema dove voglio!
    Alla batteria dai retta ballA

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.