Skip to content

Commit

Permalink
Add toLongUNCPath() module.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Aug 21, 2017
1 parent a2847fc commit 339f92e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/builtin-compilers.js
@@ -1,7 +1,7 @@
import FastObject from "./fast-object.js"

import { _makeLong } from "path"
import readFile from "./fs/read-file.js"
import toLongUNCPath from "./util/to-long-unc-path.js"

const { dlopen } = process
const { parse:jsonParse } = JSON
Expand All @@ -20,7 +20,7 @@ builtinCompilers[".json"] = function (mod, filePath) {
}

builtinCompilers[".node"] = function (mod, filePath) {
return dlopen(mod, _makeLong(filePath))
return dlopen(mod, toLongUNCPath(filePath))
}

export default builtinCompilers
4 changes: 2 additions & 2 deletions src/fs/read-file.js
@@ -1,7 +1,7 @@
import { _makeLong } from "path"
import binding from "../binding.js"
import isObjectLike from "../util/is-object-like.js"
import { readFileSync } from "fs"
import toLongUNCPath from "../util/to-long-unc-path.js"

const { internalModuleReadFile } = binding.fs
let useReadFileFastPath = typeof internalModuleReadFile === "function"
Expand Down Expand Up @@ -30,7 +30,7 @@ function fastPathReadFile(filePath) {
// Used to speed up reading. Returns the contents of the file as a string
// or undefined when the file cannot be opened. The speedup comes from not
// creating Error objects on failure.
const content = internalModuleReadFile(_makeLong(filePath))
const content = internalModuleReadFile(toLongUNCPath(filePath))
return content === void 0 ? null : content
}

Expand Down
6 changes: 3 additions & 3 deletions src/fs/stat.js
@@ -1,6 +1,6 @@
import { _makeLong } from "path"
import binding from "../binding.js"
import { Stats, statSync } from "fs"
import binding from "../binding.js"
import toLongUNCPath from "../util/to-long-unc-path.js"

const { internalModuleStat } = binding.fs
const isFile = Stats.prototype.isFile
Expand Down Expand Up @@ -44,7 +44,7 @@ function fastPathStat(filePath) {
// Used to speed up loading. Returns 0 if the path refers to a file,
// 1 when it's a directory or < 0 on error (usually ENOENT). The speedup
// comes from not creating thousands of Stat and Error objects.
return internalModuleStat(_makeLong(filePath))
return internalModuleStat(toLongUNCPath(filePath))
}

stat.cache = null
Expand Down
7 changes: 7 additions & 0 deletions src/util/to-long-unc-path.js
@@ -0,0 +1,7 @@
import { _makeLong, toLongUNCPath as _toLongUNCPath } from "path"

const toLongUNCPath = typeof _toLongUNCPath === "function"
? _toLongUNCPath
: _makeLong

export default toLongUNCPath

0 comments on commit 339f92e

Please sign in to comment.