         buffer = new Buffer 256
         file = fs.openSync filePath, 'r'
         bytes = fs.readSync file, buffer, 0, 256, 0
+        textOrBin = require 'istextorbinary'
         if textOrBin.isBinarySync filePath, buffer.slice(0, bytes)
-          return new HEXEditor(path: filePath)
+          return new (require './hex-editor')(path: filePath)
 
   @deactivate: ->
     @opener.dispose()

    '.bf': (filePath) ->
      try return new (require './beyond-good-and-evil-bf-editor')(path: filePath) catch
      return null
    '.gltf': (filePath) -> return new GLTFEditor(path: filePath)

  @activate: ->
    @opener = atom.workspace.addOpener (filePath = '') =>
      if fs.isFileSync(filePath)
        extName = path.extname(filePath).toLowerCase()

module.exports =
class GameDataExplorer
  @editors:
    '.key': (filePath) ->
      try return new (require './aurora-keyv1-editor')(path: filePath) catch
      return null
    '.mdl': (filePath) -> return new (require './mdl-editor')(path: filePath)
    '.tga': (filePath) -> return new (require './tga-editor')(path: filePath)
    '.wav': (filePath) -> return new (require './wav-editor')(path: filePath)
    '.wad': (filePath) -> return new (require './wav-editor')(path: filePath)
    '.waa': (filePath) -> return new (require './wav-editor')(path: filePath)
    '.wam': (filePath) -> return new (require './wav-editor')(path: filePath)
    '.wac': (filePath) -> return new (require './wav-editor')(path: filePath)
    '.dir': (filePath) ->
      try return new (require './commandos1-dir-editor')(path: filePath) catch
      return null
