Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

adbkit

Package Overview
Dependencies
Maintainers
2
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adbkit - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

lib/adb/sync/entry.js

15

lib/adb/client.js

@@ -372,2 +372,17 @@ (function() {

Client.prototype.readdir = function(serial, path, callback) {
return this.syncService(serial, function(err, sync) {
if (err) {
return callback(err);
}
return sync.readdir(path, function(err, files) {
sync.end();
if (err) {
return callback(err);
}
return callback(null, files);
});
});
};
Client.prototype.pull = function(serial, path, callback) {

@@ -374,0 +389,0 @@ return this.syncService(serial, function(err, sync) {

4

lib/adb/protocol.js

@@ -13,2 +13,6 @@ (function() {

Protocol.LIST = 'LIST';
Protocol.DENT = 'DENT';
Protocol.RECV = 'RECV';

@@ -15,0 +19,0 @@

(function() {
var EventEmitter, Fs, Path, Protocol, PullTransfer, PushTransfer, Stats, Sync, debug, once,
var Entry, EventEmitter, Fs, Path, Protocol, PullTransfer, PushTransfer, Stats, Sync, debug, once,
__hasProp = {}.hasOwnProperty,

@@ -20,2 +20,4 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

Entry = require('./sync/entry');
PushTransfer = require('./sync/pushtransfer');

@@ -71,2 +73,38 @@

Sync.prototype.readdir = function(path, callback) {
var files, readBlock,
_this = this;
files = [];
readBlock = function() {
return _this.parser.readAscii(4, function(reply) {
switch (reply) {
case Protocol.DENT:
return _this.parser.readBytes(16, function(stat) {
var mode, mtime, namelen, size;
mode = stat.readUInt32LE(0);
size = stat.readUInt32LE(4);
mtime = stat.readUInt32LE(8);
namelen = stat.readUInt32LE(12);
return _this.parser.readBytes(namelen, function(name) {
name = name.toString();
if (!(name === '.' || name === '..')) {
files.push(new Entry(name, mode, size, mtime));
}
return setImmediate(readBlock);
});
});
case Protocol.DONE:
return callback(null, files);
case Protocol.FAIL:
return _this._readError(callback);
default:
return _this.parser.unexpected(reply, callback);
}
});
};
readBlock();
this._sendCommandWithArg(Protocol.LIST, path);
return this;
};
Sync.prototype.push = function(contents, path, mode, callback) {

@@ -73,0 +111,0 @@ if (typeof contents === 'string') {

2

package.json
{
"name": "adbkit",
"version": "1.0.1",
"version": "1.0.2",
"description": "A pure Node.js client for the Android Debug Bridge.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -125,2 +125,21 @@ # adbkit

#### List files in a folder
```js
var adb = require('adbkit');
var client = adb.createClient();
client.listDevices(function(err, devices) {
devices.forEach(function(device) {
client.readdir(device.id, '/sdcard', function(err, files) {
files.forEach(function(file) {
if (file.isFile()) {
console.log("Found file '%s' in /sdcard", file.name);
}
});
});
});
});
```
## API

@@ -394,2 +413,11 @@

#### client.readdir(serial, path, callback)
A convenience shortcut for `sync.readdir()`, mainly for one-off use cases. The connection cannot be reused, resulting in poorer performance over multiple calls. However, the Sync client will be closed automatically for you, so that's one less thing to worry about.
* **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
* **path** See `sync.readdir()` for details.
* **callback(err, files)** See `sync.readdir()` for details.
* Returns: The client instance.
#### client.remount(serial, callback)

@@ -546,2 +574,16 @@

#### sync.readdir(path, callback)
Retrieves a list of directory entries (e.g. files) in the given path, not including the `.` and `..` entries, just like [`fs.readdir`][node-fs]. If given a non-directory path, no entries are returned.
* **path** The path.
* **callback(err, files)**
- **err** `null` when successful, `Error` otherwise.
- **files** An `Array` of [`fs.Stats`][node-fs-stats]-compatible instances. While the `stats.is*` methods are available, only the following properties are supported (in addition to the `name` field which contains the filename):
* **name** The filename.
* **mode** The raw mode.
* **size** The file size.
* **mtime** The time of last modification as a `Date`.
* Returns: The sync instance.
#### sync.stat(path, callback)

@@ -548,0 +590,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc