示例#1
0
int main(int argc,char *argv[])
{
    char path[MAX_FILE_PATH];
    char procname[100];
    DIR *dirp;
    struct dirent *dp;

    if (argc < 2 || strcmp(argv[1],"--help") == 0)
    {
        usageErr("usage:%s filepath\n",argv[0]);
    }

    /* Open dir */
    dirp = opendir("/proc");
    if (dirp == NULL)
    {
        errExit("open dir");
    }

    printf("                 This proc open file %s\n",argv[1]);
    printf("==================================================================\n");
    printf("%-40s%15s\n","Name","PID");
    printf("==================================================================\n");
    /* transfer dir */
    for (;;)
    {
        memset(path,MAX_FILE_PATH,0);
        errno = 0;
        dp = readdir(dirp);

        if (dp == NULL)
        {
            break;
        }

        if (dp->d_type != DT_DIR || strcmp(dp->d_name,".") == 0
                || strcmp(dp->d_name,"..") == 0 || !isdigit((unsigned char)dp->d_name[0]))
        {
            continue;
        }

        strcpy(path,"/proc/");
        strcat(path,dp->d_name);
        strcat(path,"/fd");

        if (isOpenFile(path,argv[1]) == 1)
        {
            getProcName(dp->d_name,procname);
            printf("%-40s%15d\n",procname,getInt(dp->d_name,GN_NONNEG,"pid"));
        }
    }

    if (closedir(dirp) == -1)
    {
        errExit("close dir");
    }
}
示例#2
0
bool
AudioRecord::toggleRecording()
{
    if (isOpenFile())
        recordingEnabled_ = !recordingEnabled_;
    else if (openFile()) {
        recordingEnabled_ = true;
        recorder_.start();
    }

    return recordingEnabled_;
}
示例#3
0
bool AudioRecord::setRecording()
{

    if (isOpenFile()) {
        if (!recordingEnabled_) {
            _info ("AudioRecording: Start recording");
            recordingEnabled_ = true;
        } else {
            recordingEnabled_ = false;
            _info ("AudioRecording: Stop recording");
        }
    } else {
        openFile();

        recordingEnabled_ = true; // once opend file, start recording
    }

    // WARNING: Unused return value
    return true;

}
示例#4
0
Co2Mgr::~Co2Mgr()
{
    if(isOpenFile())
        assert(closeFile());

}