Changeset 8565a42 in mainline for uspace/app/bdsh/cmds/modules/ls/ls.c
- Timestamp:
- 2018-03-02T20:34:50Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a1a81f69, d5e5fd1
- Parents:
- 3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
- git-committer:
- GitHub <noreply@…> (2018-03-02 20:34:50)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/ls/ls.c
r3061bc1 r8565a42 111 111 struct dir_elem_t const *da = a; 112 112 struct dir_elem_t const *db = b; 113 113 114 114 if ((da->s.is_directory && db->s.is_file) || 115 115 ((da->s.is_directory == db->s.is_directory) && … … 141 141 struct dir_elem_t *tosort; 142 142 struct dirent *dp; 143 143 144 144 if (!dirp) 145 145 return -1; … … 150 150 return -1; 151 151 } 152 152 153 153 tosort = (struct dir_elem_t *) malloc(alloc_blocks * sizeof(*tosort)); 154 154 if (!tosort) { … … 157 157 return -1; 158 158 } 159 159 160 160 while ((dp = readdir(dirp))) { 161 161 if (nbdirs + 1 > alloc_blocks) { 162 162 alloc_blocks += alloc_blocks; 163 163 164 164 tmp = (struct dir_elem_t *) realloc(tosort, 165 165 alloc_blocks * sizeof(struct dir_elem_t)); … … 170 170 tosort = tmp; 171 171 } 172 172 173 173 /* fill the name field */ 174 174 tosort[nbdirs].name = (char *) malloc(str_size(dp->d_name) + 1); … … 189 189 } 190 190 } 191 191 192 192 if (ls.sort) 193 193 qsort(&tosort[0], nbdirs, sizeof(struct dir_elem_t), ls_cmp); 194 194 195 195 for (i = 0; i < nbdirs; i++) 196 196 ls_print(&tosort[i]); … … 214 214 } 215 215 } 216 216 217 217 out: 218 218 for(i = 0; i < nbdirs; i++) … … 239 239 DIR *subdirp; 240 240 struct dir_elem_t *dir_list; 241 241 242 242 const char * const trailing_slash = "/"; 243 243 … … 294 294 } 295 295 } 296 296 297 297 ret = CMD_SUCCESS; 298 298 … … 355 355 356 356 argc = cli_count_args(argv); 357 357 358 358 for (c = 0, optreset = 1, optind = 0, opt_ind = 0; c != -1;) { 359 359 c = getopt_long(argc, argv, "hur", long_options, &opt_ind);
Note:
See TracChangeset
for help on using the changeset viewer.