Skip to content
Advertisement

Tag: unix

How to obtain total available disk space in Posix systems?

I’m writing a cross-platform application, and I need the total available disk space. For posix systems (Linux and Macos) I’m using statvfs. I created this C++ method: Unfortunately I’m getting quite strange values I can’t understand. For instance: f_blocks = 73242188 f_bsize = 1048576 f_bfree = 50393643 … Are those values in bits, bytes or anything else? I read here

Regarding the Single and the Double Dot within Directories

Whenever we use the command: and We see 2 kinds of dots: Appear in the directories. Now in APUE by Stephens Rago, it says these are filenames and some books say these are directories. What are these Dots about anyway? Please provide an answer w.r.t. Windows as well as Unix if possible. Answer It’s the same for both platforms (and

BASH: how to perform arithmetic on numbers in a pipe

I am getting a stream of numbers in a pipe, and would like to perform some operations before passing them on to the next section, but I’m a little lost about how I would go about it without breaking the pipe. for example Would you have any ideas on how to make something like this work? The actual operation I

Parsing line with delimiter in Python

I have lines of data which I want to parse. The data looks like this: What I want to do is to have a subroutine that parse them and return 2 values (score and expect) for each line. However this function of mine doesn’t seem to work: Please advice what’s the right way to do it? Answer It looks like

Get directory path by fd

I’ve run into the need to be able refer to a directory by path given its file descriptor in Linux. The path doesn’t have to be canonical, it just has to be functional so that I can pass it to other functions. So, taking the same parameters as passed to a function like fstatat(), I need to be able to

Advertisement