lib/safeFile.js
function safeReadFileSync (fileName, options) {
    verifyFileName (fileName);
    
    // if fileName exists, verify it is a file
    var info = getFileInfo (fileName);
    if ((info.exists) && (info.isFile === false)) {
        var message = format (cc.MSG_IS_NOT_A_FILE, fileName);
        throw new SafeFileError (cc.IS_NOT_A_FILE, message);
    }

    // get state, if auto-recovery required, perform recovery
    var state = getState (fileName);
    if (state.status === cc.SAFE_RECOVERABLE) {
        performRecovery (state, true);
    }

    // perform read on file
    return (readFileSync (fileName, options));
}
function safeReadFileSync (fileName, options) {
    verifyFileName (fileName);
    
    // if fileName exists, verify it is a file
    var info = getFileInfo (fileName);
    if ((info.exists) && (info.isFile === false)) {
        var message = format (cc.MSG_IS_NOT_A_FILE, fileName);
        throw new SafeFileError (cc.IS_NOT_A_FILE, message);
    }

    // get state, if auto-recovery required, perform recovery
    var state = getState (fileName);
    if (state.status === cc.SAFE_RECOVERABLE) {
        performRecovery (state, true);
    }

    // perform read on file
    return (readFileSync (fileName, options));
}
function safeReadFileSync ( fileName , options ) { verifyFileName ( fileName ) ; // if fileName exists, verify it is a file var info = getFileInfo ( fileName ) ; if ( ( info . exists ) && ( info . isFile === false ) ) { var message = format ( cc . MSG_IS_NOT_A_FILE , fileName ) ; throw new SafeFileError ( cc . IS_NOT_A_FILE , message ) ; } // get state, if auto-recovery required, perform recovery var state = getState ( fileName ) ; if ( state . status === cc . SAFE_RECOVERABLE ) { performRecovery ( state , true ) ; } // perform read on file return ( readFileSync ( fileName , options ) ) ; }
Read a file, performing recovery processing if necessary.
@param {String} file File to read.
@returns {String} Data read from file.
@throws SafeFileError
Read a file performing recovery processing if necessary .