washyflashy 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/engine.c +32 -0
- package/index.js +22 -0
- package/package.json +10 -0
package/engine.c
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#include <stdio.h>
|
|
2
|
+
#include <stdlib.h>
|
|
3
|
+
|
|
4
|
+
int main(int argc, char *argv[]) {
|
|
5
|
+
if (argc < 3) return 1;
|
|
6
|
+
|
|
7
|
+
FILE *src = fopen(argv[1], "rb");
|
|
8
|
+
FILE *dst = fopen(argv[2], "wb");
|
|
9
|
+
|
|
10
|
+
if (!src || !dst) {
|
|
11
|
+
printf("❌ FlashyWashy couldn't find the 'laundry' (files).\n");
|
|
12
|
+
return 1;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 1MB Buffer for massive speed
|
|
16
|
+
char *buffer = malloc(1024 * 1024);
|
|
17
|
+
size_t bytes;
|
|
18
|
+
|
|
19
|
+
printf("🧼 FLASHYWASHY: Scrubbing 400MB into the SanDisk...\n");
|
|
20
|
+
|
|
21
|
+
while ((bytes = fread(buffer, 1, 1024 * 1024, src)) > 0) {
|
|
22
|
+
fwrite(buffer, 1, bytes, dst);
|
|
23
|
+
printf("🌀"); fflush(stdout); // Spin cycle!
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
printf("\n✨ Squeaky Clean! Ejecting now...\n");
|
|
27
|
+
|
|
28
|
+
free(buffer);
|
|
29
|
+
fclose(src);
|
|
30
|
+
fclose(dst);
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { execSync } = require('child_process');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
const [,, src, dest] = process.argv;
|
|
6
|
+
|
|
7
|
+
if (!src || !dest) {
|
|
8
|
+
console.log("Usage: flashywashy <source> <destination>");
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Compile the C engine on the fly if needed
|
|
13
|
+
const enginePath = path.join(__dirname, 'engine');
|
|
14
|
+
try {
|
|
15
|
+
execSync(`gcc ${path.join(__dirname, 'engine.c')} -o ${enginePath}`);
|
|
16
|
+
execSync(`${enginePath} ${src} ${dest}`);
|
|
17
|
+
|
|
18
|
+
// Auto-eject for the Pi!
|
|
19
|
+
execSync(`diskutil eject /Volumes/LAK_BOOT`);
|
|
20
|
+
} catch (err) {
|
|
21
|
+
console.error("🚨 FlashyWashy tripped over a sock: ", err.message);
|
|
22
|
+
}
|