savedir.c (56230) | savedir.c (56915) |
---|---|
1/* savedir.c -- save the list of files in a directory in a string 2 Copyright (C) 1990, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2, or (at your option) 7 any later version. 8 --- 62 unchanged lines hidden (view full) --- 71/* Return a freshly allocated string containing the filenames 72 in directory DIR, separated by '\0' characters; 73 the end is marked by two '\0' characters in a row. 74 NAME_SIZE is the number of bytes to initially allocate 75 for the string; it will be enlarged as needed. 76 Return NULL if DIR cannot be opened or if out of memory. */ 77 78char * | 1/* savedir.c -- save the list of files in a directory in a string 2 Copyright (C) 1990, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2, or (at your option) 7 any later version. 8 --- 62 unchanged lines hidden (view full) --- 71/* Return a freshly allocated string containing the filenames 72 in directory DIR, separated by '\0' characters; 73 the end is marked by two '\0' characters in a row. 74 NAME_SIZE is the number of bytes to initially allocate 75 for the string; it will be enlarged as needed. 76 Return NULL if DIR cannot be opened or if out of memory. */ 77 78char * |
79savedir (dir, name_size) 80 const char *dir; 81 unsigned int name_size; | 79savedir (const char *dir, off_t name_size) |
82{ 83 DIR *dirp; 84 struct dirent *dp; 85 char *name_space; 86 char *namep; 87 88 dirp = opendir (dir); 89 if (dirp == NULL) --- 13 unchanged lines hidden (view full) --- 103 104 while ((dp = readdir (dirp)) != NULL) 105 { 106 /* Skip "." and ".." (some NFS filesystems' directories lack them). */ 107 if (dp->d_name[0] != '.' 108 || (dp->d_name[1] != '\0' 109 && (dp->d_name[1] != '.' || dp->d_name[2] != '\0'))) 110 { | 80{ 81 DIR *dirp; 82 struct dirent *dp; 83 char *name_space; 84 char *namep; 85 86 dirp = opendir (dir); 87 if (dirp == NULL) --- 13 unchanged lines hidden (view full) --- 101 102 while ((dp = readdir (dirp)) != NULL) 103 { 104 /* Skip "." and ".." (some NFS filesystems' directories lack them). */ 105 if (dp->d_name[0] != '.' 106 || (dp->d_name[1] != '\0' 107 && (dp->d_name[1] != '.' || dp->d_name[2] != '\0'))) 108 { |
111 unsigned size_needed = (namep - name_space) + NAMLEN (dp) + 2; | 109 off_t size_needed = (namep - name_space) + NAMLEN (dp) + 2; |
112 113 if (size_needed > name_size) 114 { 115 char *new_name_space; 116 117 while (size_needed > name_size) 118 name_size += 1024; 119 --- 20 unchanged lines hidden --- | 110 111 if (size_needed > name_size) 112 { 113 char *new_name_space; 114 115 while (size_needed > name_size) 116 name_size += 1024; 117 --- 20 unchanged lines hidden --- |