[英]How to write your own ls command and make it run on Rooted Android Terminal?
I want to write my own ls command,so that i could safely parse it. 我想编写自己的ls命令,以便可以安全地解析它。
I have written the following code in c. 我在c中编写了以下代码。 But how to make this .c file run in terminal emulator for android.?
但是如何使此.c文件在Android的终端仿真器中运行? Do i need to simply put it in /system/bin directory?
我是否只需将其放在/ system / bin目录中?
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
int main(int argc, char* argv[])
{
DIR *mydir;
struct dirent *myfile;
struct stat mystat;
char buf[512];
mydir = opendir(argv[1]);
while((myfile = readdir(mydir)) != NULL)
{
sprintf(buf, "%s/%s", argv[1], myfile->d_name);
stat(buf, &mystat);
printf("%zu",mystat.st_size);
printf(" %s\n", myfile->d_name);
}
closedir(mydir);
}
No. Why would you think that would work? 否。您为什么认为这行得通? C is a compiled language, not interpreted.
C是一种编译语言,无法解释。 You'd need to compile it for ARM linux first.
您需要首先针对ARM linux对其进行编译。 (I'm assuming ARM, as most devices are- your mileage may vary, and you may need to compile for the correct version of ARM).
(我假设ARM,因为大多数设备都是这样-您的工作量可能会有所不同,并且可能需要针对正确版本的ARM进行编译)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.