Skip to content
Snippets Groups Projects
Select Git revision
  • 60fdac0680750e660d2af0b06dde02d5da0ca57c
  • zig default
  • master
  • zig-threaded
  • openat
  • chdir
  • clear
  • compll
  • v1.18.1
  • v2.2.2
  • v1.18
  • v2.2.1
  • v2.2
  • v1.17
  • v2.1.2
  • v2.1.1
  • v2.1
  • v2.0.1
  • v2.0
  • v2.0-beta3
  • v2.0-beta2
  • v2.0-beta1
  • v1.16
  • v1.15.1
  • v1.15
  • v1.14.2
  • v1.14.1
  • v1.14
28 results

dirlist.c

Blame
  • dirlist.c 9.83 KiB
    /* ncdu - NCurses Disk Usage
    
      Copyright (c) 2007-2018 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 "global.h"
    
    #include <string.h>
    #include <stdlib.h>
    
    
    /* public variables */
    struct dir *dirlist_parent = NULL,
               *dirlist_par    = NULL;
    int64_t dirlist_maxs       = 0,
            dirlist_maxa       = 0;
    
    int    dirlist_sort_desc   = 1,
           dirlist_sort_col    = DL_COL_SIZE,
           dirlist_sort_df     = 0,
           dirlist_hidden      = 0;
    
    /* private state vars */
    static struct dir *parent_alloc, *head, *head_real, *selected, *top = NULL;
    
    
    
    #define ISHIDDEN(d) (dirlist_hidden && (d) != dirlist_parent && (\
        (d)->flags & FF_EXL || (d)->name[0] == '.' || (d)->name[strlen((d)->name)-1] == '~'\
      ))
    
    
    static inline int cmp_mtime(struct dir *x, struct dir*y) {
      int64_t x_mtime = 0, y_mtime = 0;
      if (x->flags & FF_EXT)
        x_mtime = dir_ext_ptr(x)->mtime;
      if (y->flags & FF_EXT)
        y_mtime = dir_ext_ptr(y)->mtime;
      return (x_mtime > y_mtime ? 1 : (x_mtime == y_mtime ? 0 : -1));
    }
    
    static int dirlist_cmp(struct dir *x, struct dir *y) {
      int r;
    
      /* dirs are always before files when that option is set */
      if(dirlist_sort_df) {
        if(y->flags & FF_DIR && !(x->flags & FF_DIR))
          return 1;
        else if(!(y->flags & FF_DIR) && x->flags & FF_DIR)
          return -1;