Files
aitbc/dev/env/node_modules/adm-zip/util/utils.js
aitbc 816e258d4c refactor: move brother_node development artifact to dev/test-nodes subdirectory
Development Artifact Cleanup:
 BROTHER_NODE REORGANIZATION: Moved development test node to appropriate location
- dev/test-nodes/brother_node/: Moved from root directory for better organization
- Contains development configuration, test logs, and test chain data
- No impact on production systems - purely development/testing artifact

 DEVELOPMENT ARTIFACTS IDENTIFIED:
- Chain ID: aitbc-brother-chain (test/development chain)
- Ports: 8010 (P2P) and 8011 (RPC) - different from production
- Environment: .env file with test configuration
- Logs: rpc.log and node.log from development testing session (March 15, 2026)

 ROOT DIRECTORY CLEANUP: Removed development clutter from production directory
- brother_node/ moved to dev/test-nodes/brother_node/
- Root directory now contains only production-ready components
- Development artifacts properly organized in dev/ subdirectory

DIRECTORY STRUCTURE IMPROVEMENT:
📁 dev/test-nodes/: Development and testing node configurations
🏗️ Root Directory: Clean production structure with only essential components
🧪 Development Isolation: Test environments separated from production

BENEFITS:
 Clean Production Directory: No development artifacts in root
 Better Organization: Development nodes grouped in dev/ subdirectory
 Clear Separation: Production vs development environments clearly distinguished
 Maintainability: Easier to identify and manage development components

RESULT: Successfully moved brother_node development artifact to dev/test-nodes/ subdirectory, cleaning up the root directory while preserving development testing environment for future use.
2026-03-30 17:09:06 +02:00

219 lines
7.4 KiB
JavaScript
Executable File

var fs = require("./fileSystem").require(),
pth = require('path');
fs.existsSync = fs.existsSync || pth.existsSync;
module.exports = (function() {
var crcTable = [],
Constants = require('./constants'),
Errors = require('./errors'),
PATH_SEPARATOR = pth.sep;
function mkdirSync(/*String*/path) {
var resolvedPath = path.split(PATH_SEPARATOR)[0];
path.split(PATH_SEPARATOR).forEach(function(name) {
if (!name || name.substr(-1,1) === ":") return;
resolvedPath += PATH_SEPARATOR + name;
var stat;
try {
stat = fs.statSync(resolvedPath);
} catch (e) {
fs.mkdirSync(resolvedPath);
}
if (stat && stat.isFile())
throw Errors.FILE_IN_THE_WAY.replace("%s", resolvedPath);
});
}
function findSync(/*String*/dir, /*RegExp*/pattern, /*Boolean*/recoursive) {
if (typeof pattern === 'boolean') {
recoursive = pattern;
pattern = undefined;
}
var files = [];
fs.readdirSync(dir).forEach(function(file) {
var path = pth.join(dir, file);
if (fs.statSync(path).isDirectory() && recoursive)
files = files.concat(findSync(path, pattern, recoursive));
if (!pattern || pattern.test(path)) {
files.push(pth.normalize(path) + (fs.statSync(path).isDirectory() ? PATH_SEPARATOR : ""));
}
});
return files;
}
function readBigUInt64LE(/*Buffer*/buffer, /*int*/index) {
var slice = Buffer.from(buffer.slice(index, index + 8));
slice.swap64();
return parseInt(`0x${ slice.toString('hex') }`);
}
return {
makeDir : function(/*String*/path) {
mkdirSync(path);
},
crc32 : function(buf) {
if (typeof buf === 'string') {
buf = Buffer.alloc(buf.length, buf);
}
var b = Buffer.alloc(4);
if (!crcTable.length) {
for (var n = 0; n < 256; n++) {
var c = n;
for (var k = 8; --k >= 0;) //
if ((c & 1) !== 0) { c = 0xedb88320 ^ (c >>> 1); } else { c = c >>> 1; }
if (c < 0) {
b.writeInt32LE(c, 0);
c = b.readUInt32LE(0);
}
crcTable[n] = c;
}
}
var crc = 0, off = 0, len = buf.length, c1 = ~crc;
while(--len >= 0) c1 = crcTable[(c1 ^ buf[off++]) & 0xff] ^ (c1 >>> 8);
crc = ~c1;
b.writeInt32LE(crc & 0xffffffff, 0);
return b.readUInt32LE(0);
},
methodToString : function(/*Number*/method) {
switch (method) {
case Constants.STORED:
return 'STORED (' + method + ')';
case Constants.DEFLATED:
return 'DEFLATED (' + method + ')';
default:
return 'UNSUPPORTED (' + method + ')';
}
},
writeFileTo : function(/*String*/path, /*Buffer*/content, /*Boolean*/overwrite, /*Number*/attr) {
if (fs.existsSync(path)) {
if (!overwrite)
return false; // cannot overwrite
var stat = fs.statSync(path);
if (stat.isDirectory()) {
return false;
}
}
var folder = pth.dirname(path);
if (!fs.existsSync(folder)) {
mkdirSync(folder);
}
var fd;
try {
fd = fs.openSync(path, 'w', 438); // 0666
} catch(e) {
fs.chmodSync(path, 438);
fd = fs.openSync(path, 'w', 438);
}
if (fd) {
try {
fs.writeSync(fd, content, 0, content.length, 0);
}
catch (e){
throw e;
}
finally {
fs.closeSync(fd);
}
}
fs.chmodSync(path, attr || 438);
return true;
},
writeFileToAsync : function(/*String*/path, /*Buffer*/content, /*Boolean*/overwrite, /*Number*/attr, /*Function*/callback) {
if(typeof attr === 'function') {
callback = attr;
attr = undefined;
}
fs.exists(path, function(exists) {
if(exists && !overwrite)
return callback(false);
fs.stat(path, function(err, stat) {
if(exists &&stat.isDirectory()) {
return callback(false);
}
var folder = pth.dirname(path);
fs.exists(folder, function(exists) {
if(!exists)
mkdirSync(folder);
fs.open(path, 'w', 438, function(err, fd) {
if(err) {
fs.chmod(path, 438, function() {
fs.open(path, 'w', 438, function(err, fd) {
fs.write(fd, content, 0, content.length, 0, function() {
fs.close(fd, function() {
fs.chmod(path, attr || 438, function() {
callback(true);
})
});
});
});
})
} else {
if(fd) {
fs.write(fd, content, 0, content.length, 0, function() {
fs.close(fd, function() {
fs.chmod(path, attr || 438, function() {
callback(true);
})
});
});
} else {
fs.chmod(path, attr || 438, function() {
callback(true);
})
}
}
});
})
})
})
},
findFiles : function(/*String*/path) {
return findSync(path, true);
},
getAttributes : function(/*String*/path) {
},
setAttributes : function(/*String*/path) {
},
toBuffer : function(input) {
if (Buffer.isBuffer(input)) {
return input;
} else {
if (input.length === 0) {
return Buffer.alloc(0)
}
return Buffer.from(input, 'utf8');
}
},
readBigUInt64LE,
Constants : Constants,
Errors : Errors
}
})();