简体   繁体   English

如何编写自己的ls命令并使它在Rooted Android Terminal上运行?

[英]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.

相关问题 有根 Android 的终端命令将 /System 重新挂载为读/写 - A terminal command for a rooted Android to remount /System as read/write 如何在Android应用中运行重命名Shell命令 - How to run rename shell command in android app (rooted) 如何制作自己的地图以便在Android上应用? - How to make your own map for application on Android? 如何在根仿真器上创建的android应用程序中运行终端命令? - How do you run terminal commands in a created android application on rooted emulator? 如何在Android应用程序中运行终端命令? - How to run terminal command in Android application? 如何从命令行使用 cmake 为有根的 Android 设备制作可执行文件? - How to use cmake from command line to make an executable for rooted Android device? 如何在没有植入设备的情况下使用自己的Android服务进行屏幕捕获? - How to Screen Capture With Own android Service without Rooted Device? 如何在根植于Android的Oreo中授予WRITE_APN_SETTINGS权限 - How to grant WRITE_APN_SETTINGS permission in android rooted oreo Android:如何在Android中加密自己的数据库 - Android: How to encrypt your own database in Android 如何为 Android 开发创建自己的库,以便在您编写的每个程序中使用? - How to create your own library for Android development to be used in every program you write?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM