Changeset 11882

Show
Ignore:
Timestamp:
08/13/07 22:13:02 (1 year ago)
Author:
ilucena
Message:

Reforma RDC files as CRLF in UNIX

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gdal/frmts/idrisi/IdrisiDataset.cpp

    r11865 r11882  
    244244int GetToMeterIndex( const char *pszToMeter ); 
    245245 
     246//----- FormatCRLF 
     247void FormatCRLF( const char *pszFilename ); 
     248 
    246249//----- Classes pre-definition: 
    247250class IdrisiDataset; 
     
    384387            CSLSetNameValueSeparator( papszRDC, ": " ); 
    385388            CSLSave( papszRDC, pszDocFilename ); 
     389#ifndef WIN32         
     390            FormatCRLF( pszDocFilename ); 
     391#endif  
    386392        } 
    387393        CSLDestroy( papszRDC ); 
     
    755761    CSLSetNameValueSeparator( papszLRDC, ": " ); 
    756762    CSLSave( papszLRDC, pszLDocFilename ); 
     763#ifndef WIN32         
     764    FormatCRLF( pszLDocFilename ); 
     765#endif  
    757766    CSLDestroy( papszLRDC ); 
    758767 
     
    25682577    CSLSetNameValueSeparator( papszRef, ": " ); 
    25692578    CSLSave( papszRef, CPLResetExtension( pszFilename, extREF ) ); 
     2579#ifndef WIN32         
     2580    FormatCRLF( CPLResetExtension( pszFilename, extREF ) ); 
     2581#endif  
    25702582    CSLDestroy( papszRef ); 
    25712583 
     
    26842696 
    26852697    return CPLStrdup( aoLinearUnitsConv[aoLinearUnitsConv[nIndex].nDefaultI].pszName ); 
     2698} 
     2699 
     2700/************************************************************************/ 
     2701/*                               FormatCRLF()                           */ 
     2702/************************************************************************/ 
     2703 
     2704void FormatCRLF( const char *pszFilename ) 
     2705{ 
     2706    const char *pszTempfile; 
     2707    FILE *fpIn; 
     2708    FILE *fpOut; 
     2709    char ch; 
     2710 
     2711    pszTempfile = CPLResetExtension( pszFilename, "$$$" ); 
     2712 
     2713    fpIn  = VSIFOpen( pszFilename, "r" ); 
     2714    fpOut = VSIFOpen( pszTempfile, "w" ); 
     2715 
     2716    if ( fpIn == NULL ) 
     2717    { 
     2718        return; 
     2719    } 
     2720 
     2721    if ( fpOut == NULL ) 
     2722    { 
     2723        VSIFClose( fpIn ); 
     2724        return; 
     2725    } 
     2726 
     2727    // Copy data 
     2728 
     2729    ch = VSIFGetc( fpIn ); 
     2730 
     2731    while( VSIFEof( fpIn ) == FALSE ) 
     2732    { 
     2733        VSIFPutc( ch, fpOut ); 
     2734        ch = VSIFGetc( fpIn ); 
     2735    } 
     2736 
     2737    VSIFClose( fpIn ); 
     2738    VSIFClose( fpOut ); 
     2739 
     2740    // Convert format 
     2741 
     2742    fpIn  = VSIFOpen( pszTempfile, "r" ); 
     2743    fpOut = VSIFOpen( pszFilename, "w" ); 
     2744 
     2745    if ( fpIn == NULL ) 
     2746    { 
     2747        return; 
     2748    } 
     2749 
     2750    if ( fpOut == NULL ) 
     2751    { 
     2752        VSIFClose( fpIn ); 
     2753        return; 
     2754    } 
     2755 
     2756    ch = VSIFGetc( fpIn ); 
     2757 
     2758    while( VSIFEof( fpIn ) == FALSE ) 
     2759    { 
     2760        if( ch == '\012' ) 
     2761        { 
     2762            VSIFPutc( '\015', fpOut ); 
     2763        }      
     2764        VSIFPutc( ch, fpOut ); 
     2765        ch = VSIFGetc( fpIn ); 
     2766    } 
     2767 
     2768    VSIFClose( fpIn ); 
     2769    VSIFClose( fpOut ); 
     2770 
     2771    VSIUnlink( pszTempfile );     
    26862772} 
    26872773