none
Why fprintf or fflush not throw a error when UNC is inactive RRS feed

  • Pergunta

  • i guys,

    I'm seeing that fprintf or fflush not throw a error when a UNC path( \\computer-name\shared\logs\seq.txt ) is inactive. 

    I started my app and i'm unplugging network cable.

    fprintf or fflush not return error when UNC path is inactive.

    Somebody knows something about this? 

    // app sample

    std::string m_seqNumsFileName("\\\\comp-1\\storage\\logs\\seq.txt"); FILE* m_seqNumsFile = NULL; errno_t i = 0; i = fopen_s( &m_seqNumsFile, m_seqNumsFileName.c_str(), "r+" ); if ( !m_seqNumsFile ) i = fopen_s( &m_seqNumsFile, m_seqNumsFileName.c_str(), "w+" ); int iSender = 0, iTarget = 0; for( int a = 0; a < 100; a++ ) { rewind( m_seqNumsFile ); fprintf( m_seqNumsFile, "%10.10d : %10.10d", iSender++, iTarget++ );

    if( iSender > 10 ) // Unplugging network cable

    if ( ferror( m_seqNumsFile ) ) throw std::exception( "Unable to write to file " ); if ( fflush( m_seqNumsFile ) ) throw std::exception( "Unable to flush file " ); }



    quarta-feira, 15 de maio de 2013 18:03

Todas as Respostas

  • You are using the functions's return like "boolean true"(not null) as success.
    If you read about these functions you can see they're return's "null(zero)" as success, so just change your "if conditions" and try again.

    Assembly, Delphi and C.

    quinta-feira, 16 de maio de 2013 12:23