Select Git revision
calc.c 10.90 KiB
/* ncdu - NCurses Disk Usage
Copyright (c) 2007-2009 Yoran Heling
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "ncdu.h"
#include "calc.h"
#include "exclude.h"
#include "util.h"
#include "browser.h"
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <dirent.h>
/* set S_BLKSIZE if not defined already in sys/stat.h */
#ifndef S_BLKSIZE
# define S_BLKSIZE 512
#endif
#ifndef LINK_MAX
# ifdef _POSIX_LINK_MAX
# define LINK_MAX _POSIX_LINK_MAX
# else
# define LINK_MAX 32
# endif
#endif
#ifndef S_ISLNK
# ifndef S_IFLNK
# define S_IFLNK 0120000
# endif
# define S_ISLNK(x) (x & S_IFLNK)
#endif
/* external vars */
int calc_delay = 100;
char calc_smfs = 0;
/* global vars for internal use */
char failed; /* 1 on fatal error */
char curpath[PATH_MAX]; /* last lstat()'ed item */