Click here to Skip to main content
14,269,309 members

Linux Programming

 
GeneralRe: system call syntax ? Pin
k50548-Feb-19 5:23
memberk50548-Feb-19 5:23 
GeneralRe: system call syntax ? Pin
Richard MacCutchan8-Feb-19 5:53
protectorRichard MacCutchan8-Feb-19 5:53 
GeneralRe: system call syntax ? Pin
Vaclav_8-Feb-19 9:42
memberVaclav_8-Feb-19 9:42 
GeneralRe: system call syntax ? Pin
k50548-Feb-19 10:03
memberk50548-Feb-19 10:03 
GeneralRe: system call syntax ? Pin
Vaclav_8-Feb-19 14:37
memberVaclav_8-Feb-19 14:37 
GeneralRe: system call syntax ? Pin
Richard MacCutchan8-Feb-19 22:27
protectorRichard MacCutchan8-Feb-19 22:27 
Questionfrom "ls" to C++ buffer? Pin
Vaclav_15-Jan-19 4:03
memberVaclav_15-Jan-19 4:03 
AnswerRe: from "ls" to C++ buffer? Pin
k505415-Jan-19 6:02
memberk505415-Jan-19 6:02 
use popen(). e.g.
#include <cstdio>

FILE *cmd = popen("ls -l -x /dev/spi*", "r");

while(!feof(cmd) && !ferr(cmd)) {
    fscanf(cmd, ...);
    // do stuff
}
fclose(cmd);

If you've got boost, then maybe boost.process will be a better fit.

If you just need filenames, maybe glob() is all you need
#include <glob>

glob_t spi_files;

glob("/dev/spi*", 0, 0, &spi_files);
for(size_t i = 0; i < spi_files.gl_pathc; ++i) {
    char *filename = gl.pathv[i];
    ...
}
globfree(&spi_files);

If you need further information about the files, then you can call stat() on the file, see man stat(2). Also see man glob(3) for the usage of arguments 2 and 3 (0s in above code).

There's also boost.filesystem, which may help you. If you've got a C++17 compilant compiler (gcc v8), then you also have <filesystem> in the stdlib
GeneralRe: from "ls" to C++ buffer? Pin
Vaclav_15-Jan-19 9:10
memberVaclav_15-Jan-19 9:10 
GeneralRe: from "ls" to C++ buffer? Pin
k505415-Jan-19 20:37
memberk505415-Jan-19 20:37 
AnswerRe: from "ls" to C++ buffer? Pin
Vaclav_15-Jan-19 14:30
memberVaclav_15-Jan-19 14:30 
GeneralRe: from "ls" to C++ buffer? Pin
Richard MacCutchan15-Jan-19 21:24
protectorRichard MacCutchan15-Jan-19 21:24 
GeneralRe: from "ls" to C++ buffer? Pin
Vaclav_16-Jan-19 7:05
memberVaclav_16-Jan-19 7:05 
GeneralRe: from "ls" to C++ buffer? Pin
Richard MacCutchan16-Jan-19 8:20
protectorRichard MacCutchan16-Jan-19 8:20 
GeneralRe: from "ls" to C++ buffer? Pin
Vaclav_16-Jan-19 15:03
memberVaclav_16-Jan-19 15:03 
Questionioctl - from code to hardware Pin
Vaclav_3-Jan-19 4:41
memberVaclav_3-Jan-19 4:41 
SuggestionRe: ioctl - from code to hardware Pin
Richard MacCutchan3-Jan-19 6:31
protectorRichard MacCutchan3-Jan-19 6:31 
GeneralRe: ioctl - from code to hardware Pin
Vaclav_3-Jan-19 11:03
memberVaclav_3-Jan-19 11:03 
GeneralRe: ioctl - from code to hardware Pin
Richard MacCutchan3-Jan-19 22:11
protectorRichard MacCutchan3-Jan-19 22:11 
GeneralRe: ioctl - from code to hardware Pin
Vaclav_4-Jan-19 5:36
memberVaclav_4-Jan-19 5:36 
QuestionWhich is most current Linux "man" resource to consult with? Pin
Vaclav_2-Jan-19 5:36
memberVaclav_2-Jan-19 5:36 
AnswerRe: Which is most current Linux "man" resource to consult with? Pin
Richard MacCutchan2-Jan-19 6:29
protectorRichard MacCutchan2-Jan-19 6:29 
QuestionCoding C++ ioctl SPI_IOC_MESSAGE Pin
Vaclav_26-Dec-18 4:44
memberVaclav_26-Dec-18 4:44 
GeneralRe: Coding C++ ioctl SPI_IOC_MESSAGE Pin
Richard MacCutchan26-Dec-18 7:01
protectorRichard MacCutchan26-Dec-18 7:01 
GeneralRe: Coding C++ ioctl SPI_IOC_MESSAGE Pin
Vaclav_26-Dec-18 7:51
memberVaclav_26-Dec-18 7:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.