From cc4a0749c7b437c4e4ceb186cca1d42f5784b723 Mon Sep 17 00:00:00 2001 From: Roee Kasher Date: Mon, 5 Mar 2018 13:55:47 +0200 Subject: [PATCH] CI fixes --- README.md | 4 ++-- src/binding.cc | 18 +++++++++++++++--- test/test.js | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 28c9b7e..03db72b 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Examples var magic = new Magic(); - magic.compile("node_modules/mmmagic/test/dummy_magic_file", function(err, result) { + magic.compile("node_modules/mmmagic/test/dummy_magic_file;node_modules/mmmagic/test/dummy_magic_file2", function(err, result) { if (err) throw err; console.log("Compiled magic file successfully. Compile file name: ", result); // output: Compiled magic file successfully. Compile file name: [ 'dummy_magic_file.mgc' ] @@ -122,4 +122,4 @@ Magic methods * **detect**(< _Buffer_ >data, < _Function_ >callback) - _(void)_ - Inspects the contents of data. The callback receives two arguments: an < _Error_ > object in case of error (null otherwise), and a < _String_ > containing the result of the inspection. -* **compile**(< _String_ >path, < _Function_ >callback) - _(void)_ - Compile a colon separated list of database files. The compiled files can be used later on with one of the other methods. The callback receives two arguments: an < _Error_ > object in case of error (null otherwise), and an array of < _String_ > containing the names of the compiled files. +* **compile**(< _String_ >path, < _Function_ >callback) - _(void)_ - Compile a semicolon separated list of database files. The compiled files can be used later on with one of the other methods. The callback receives two arguments: an < _Error_ > object in case of error (null otherwise), and an array of < _String_ > containing the names of the compiled files. diff --git a/src/binding.cc b/src/binding.cc index a68dfdc..d339ecf 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -8,6 +8,8 @@ # include # include # include +#else +# include #endif #include "magic.h" @@ -434,13 +436,23 @@ class Magic : public ObjectWrap { // Creating the list of the compiled magic files Local results = Nan::New(); uint32_t i = 0; - char *file_path = strtok(baton->data, ":"); + char *file_path = strtok(baton->data, ";"); while(file_path != NULL) { // Getting the file name from the source const char* file_path_dup = strdup(file_path); - const char* file_name = basename(file_path_dup); + const char* file_name; +#ifdef _WIN32 + char drive[_MAX_DRIVE]; + char dir[_MAX_DIR]; + char fname[_MAX_FNAME]; + char ext[_MAX_EXT]; + _splitpath_s(file_path_dup, drive, _MAX_DRIVE, dir, _MAX_DIR, fname, _MAX_FNAME, ext, _MAX_EXT); + file_name = fname; +#else + file_name = basename(file_path_dup); +#endif // Creating the name of the mgc file (which is the magic file name + ".mgc") size_t file_name_length = strlen(file_name); @@ -460,7 +472,7 @@ class Magic : public ObjectWrap { delete[] mgc_file_name; // Looking for the next file name - file_path=strtok(NULL, ":"); + file_path=strtok(NULL, ";"); } argv[1] = Local(results); diff --git a/test/test.js b/test/test.js index 0b0e3fb..9b71b34 100644 --- a/test/test.js +++ b/test/test.js @@ -112,7 +112,7 @@ var tests = [ { run: function() { var dummy_magic_file = path.join(__dirname, 'dummy_magic_file'); var dummy_magic_file2 = dummy_magic_file + "2"; - var colon_seperated_magic_files = dummy_magic_file + ":" + dummy_magic_file2; + var colon_seperated_magic_files = dummy_magic_file + ";" + dummy_magic_file2; var magic = new mmm.Magic(mmm.MAGIC_MIME_TYPE); magic.compile(colon_seperated_magic_files, function(err, result) { assert.strictEqual(err, null);