mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
add function names; cleanup
This commit is contained in:
parent
58292362b3
commit
900f9f1216
48
rhino/fs.js
48
rhino/fs.js
@ -1,5 +1,3 @@
|
|||||||
/*global env: true, Packages: true */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Partial Rhino shim for Node.js' `fs` module.
|
* Partial Rhino shim for Node.js' `fs` module.
|
||||||
* @see http://nodejs.org/api/fs.html
|
* @see http://nodejs.org/api/fs.html
|
||||||
@ -31,7 +29,7 @@ function errorFactory(filepath) {
|
|||||||
return new Error( util.format("ENOENT, no such file or directory '%s'", filepath) );
|
return new Error( util.format("ENOENT, no such file or directory '%s'", filepath) );
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.readFileSync = function(filename, encoding) {
|
exports.readFileSync = function readFileSync(filename, encoding) {
|
||||||
encoding = checkEncoding(encoding, 'fs.readFile[Sync]');
|
encoding = checkEncoding(encoding, 'fs.readFile[Sync]');
|
||||||
|
|
||||||
return readFile(filename, encoding);
|
return readFile(filename, encoding);
|
||||||
@ -42,7 +40,7 @@ exports.readFile = asyncify(exports.readFileSync);
|
|||||||
exports.existsSync = path.existsSync;
|
exports.existsSync = path.existsSync;
|
||||||
exports.exists = path.exists;
|
exports.exists = path.exists;
|
||||||
|
|
||||||
var statSync = exports.statSync = function(_path) {
|
var statSync = exports.statSync = function statSync(_path) {
|
||||||
var f = new java.io.File(_path);
|
var f = new java.io.File(_path);
|
||||||
if (!f) {
|
if (!f) {
|
||||||
throw errorFactory(_path);
|
throw errorFactory(_path);
|
||||||
@ -59,7 +57,7 @@ var statSync = exports.statSync = function(_path) {
|
|||||||
};
|
};
|
||||||
exports.stat = asyncify(statSync);
|
exports.stat = asyncify(statSync);
|
||||||
|
|
||||||
var readdirSync = exports.readdirSync = function(_path) {
|
var readdirSync = exports.readdirSync = function readdirSync(_path) {
|
||||||
var dir;
|
var dir;
|
||||||
var files;
|
var files;
|
||||||
|
|
||||||
@ -80,57 +78,61 @@ var readdirSync = exports.readdirSync = function(_path) {
|
|||||||
exports.readdir = asyncify(readdirSync);
|
exports.readdir = asyncify(readdirSync);
|
||||||
|
|
||||||
// JSDoc extension to `fs` module
|
// JSDoc extension to `fs` module
|
||||||
var toDir = exports.toDir = function(_path) {
|
var toDir = exports.toDir = function toDir(_path) {
|
||||||
var f = new java.io.File( path.resolve(env.pwd, _path) );
|
var f = new java.io.File( path.resolve(global.env.pwd, _path) );
|
||||||
|
|
||||||
if (f.isDirectory()){
|
if ( f.isDirectory() ){
|
||||||
return _path;
|
return _path;
|
||||||
} else {
|
} else {
|
||||||
return path.dirname(_path);
|
return path.dirname(_path);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var mkdirSync = exports.mkdirSync = function(_path) {
|
var mkdirSync = exports.mkdirSync = function mkdirSync(_path) {
|
||||||
var dir_path = toDir(_path);
|
var dir_path = toDir(_path);
|
||||||
(new java.io.File(dir_path)).mkdir();
|
( new java.io.File(dir_path) ).mkdir();
|
||||||
};
|
};
|
||||||
exports.mkdir = asyncify(mkdirSync);
|
exports.mkdir = asyncify(mkdirSync);
|
||||||
|
|
||||||
// JSDoc extension to `fs` module
|
// JSDoc extension to `fs` module
|
||||||
exports.mkPath = function(_path) {
|
exports.mkPath = function mkPath(_path) {
|
||||||
if ( Array.isArray(_path) ) {
|
if ( Array.isArray(_path) ) {
|
||||||
_path = _path.join('');
|
_path = _path.join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
( new java.io.File(path.resolve(env.pwd, _path)) ).mkdirs();
|
( new java.io.File(path.resolve(global.env.pwd, _path)) ).mkdirs();
|
||||||
};
|
};
|
||||||
|
|
||||||
// JSDoc extension to `fs` module
|
// JSDoc extension to `fs` module
|
||||||
exports.copyFileSync = function(inFile, outDir, fileName) {
|
exports.copyFileSync = function copyFileSync(inFile, outDir, fileName) {
|
||||||
if (fileName == null){fileName = path.basename(inFile);}
|
if (fileName === undefined || fileName === null) {
|
||||||
|
fileName = path.basename(inFile);
|
||||||
|
}
|
||||||
|
|
||||||
outDir = toDir(outDir);
|
outDir = toDir(outDir);
|
||||||
|
|
||||||
inFile = new java.io.File(inFile);
|
inFile = new java.io.File(inFile);
|
||||||
var outFile = new java.io.File(outDir+'/'+fileName);
|
var outFile = new java.io.File(outDir + '/' + fileName);
|
||||||
|
|
||||||
var bis = new Packages.java.io.BufferedInputStream(new Packages.java.io.FileInputStream(inFile), 4096);
|
var bis = new java.io.BufferedInputStream(new java.io.FileInputStream(inFile), 4096);
|
||||||
var bos = new Packages.java.io.BufferedOutputStream(new Packages.java.io.FileOutputStream(outFile), 4096);
|
var bos = new java.io.BufferedOutputStream(new java.io.FileOutputStream(outFile), 4096);
|
||||||
var theChar;
|
var theChar = bis.read();
|
||||||
while ((theChar = bis.read()) != -1) {
|
while (theChar !== -1) {
|
||||||
bos.write(theChar);
|
bos.write(theChar);
|
||||||
|
theChar = bis.read();
|
||||||
}
|
}
|
||||||
|
|
||||||
bos.close();
|
bos.close();
|
||||||
bis.close();
|
bis.close();
|
||||||
};
|
};
|
||||||
exports.copyFile = asyncify(exports.copyFileSync);
|
exports.copyFile = asyncify(exports.copyFileSync);
|
||||||
|
|
||||||
exports.writeFileSync = function(filename, data, encoding) {
|
exports.writeFileSync = function writeFileSync(filename, data, encoding) {
|
||||||
encoding = checkEncoding(encoding, 'fs.writeFile[Sync]');
|
encoding = checkEncoding(encoding, 'fs.writeFile[Sync]');
|
||||||
|
|
||||||
var out = new Packages.java.io.PrintWriter(
|
var out = new java.io.PrintWriter(
|
||||||
new Packages.java.io.OutputStreamWriter(
|
new java.io.OutputStreamWriter(
|
||||||
new Packages.java.io.FileOutputStream(filename),
|
new java.io.FileOutputStream(filename),
|
||||||
encoding
|
encoding
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user