function fileOpened (err, fd) {
    if (err) {
      sonic._reopening = false
      sonic._writing = false
      sonic._opening = false

      if (sonic.sync) {
        process.nextTick(() => {
          if (sonic.listenerCount('error') > 0) {
            sonic.emit('error', err)
          }
        })
      } else {
        sonic.emit('error', err)
      }
      return
    }

    sonic.fd = fd
    sonic.file = file
    sonic._reopening = false
    sonic._opening = false
    sonic._writing = false

    if (sonic.sync) {
      process.nextTick(() => sonic.emit('ready'))
    } else {
      sonic.emit('ready')
    }

    if (sonic._reopening) {
      return
    }

    // start
    if (!sonic._writing && sonic._len > sonic.minLength && !sonic.destroyed) {
      actualWrite(sonic)
    }
  }
// for sync mode, there is no way to add a listener that will receive these
for sync mode, there is no way to add a listener that will receive these
for sync mode there is no way to add a listener that will receive these
function fileOpened (err, fd) {
    if (err) {
      sonic._reopening = false
      sonic._writing = false
      sonic._opening = false
      if (sonic.sync) {
        process.nextTick(() => {
          if (sonic.listenerCount('error') > 0) {
            sonic.emit('error', err)
          }
        })
      } else {
        sonic.emit('error', err)
      }
      return
    }
    sonic.fd = fd
    sonic.file = file
    sonic._reopening = false
    sonic._opening = false
    sonic._writing = false
    if (sonic.sync) {
      process.nextTick(() => sonic.emit('ready'))
    } else {
      sonic.emit('ready')
    }
    if (sonic._reopening) {
      return
    }
    if (!sonic._writing && sonic._len > sonic.minLength && !sonic.destroyed) {
      actualWrite(sonic)
    }
  }
function fileOpened ( err , fd ) { if ( err ) { sonic . _reopening = false sonic . _writing = false sonic . _opening = false if ( sonic . sync ) { process . nextTick ( ( ) => { if ( sonic . listenerCount ( 'error' ) > 0 ) { sonic . emit ( 'error' , err ) } } ) } else { sonic . emit ( 'error' , err ) } return } sonic . fd = fd sonic . file = file sonic . _reopening = false sonic . _opening = false sonic . _writing = false if ( sonic . sync ) { process . nextTick ( ( ) => sonic . emit ( 'ready' ) ) } else { sonic . emit ( 'ready' ) } if ( sonic . _reopening ) { return } if ( ! sonic . _writing && sonic . _len > sonic . minLength && ! sonic . destroyed ) { actualWrite ( sonic ) } }
for sync mode, there is no way to add a listener that will receive these
for sync mode there is no way to add a listener that will receive these
// start