mirror of
https://github.com/jarun/nnn.git
synced 2025-01-15 21:36:42 +00:00
Continue listing when max files/size is exceeded
This commit is contained in:
parent
21eebbb003
commit
e8acae3274
2
nnn.1
2
nnn.1
|
@ -312,7 +312,7 @@ There are two ways to search and list:
|
||||||
.Pp
|
.Pp
|
||||||
File paths must be NUL-separated ('\\0'). Paths and can be relative to the
|
File paths must be NUL-separated ('\\0'). Paths and can be relative to the
|
||||||
current directory or absolute. Invalid paths in the input are ignored. Input
|
current directory or absolute. Invalid paths in the input are ignored. Input
|
||||||
limit is 16,384 paths or 256 MiB of data.
|
processing limit is 16,384 paths or 64 MiB (max_paths x max_path_len) of data.
|
||||||
.Pp
|
.Pp
|
||||||
To list the input stream, start
|
To list the input stream, start
|
||||||
.Nm
|
.Nm
|
||||||
|
|
42
src/nnn.c
42
src/nnn.c
|
@ -585,7 +585,7 @@ static char * const utils[] = {
|
||||||
#define MSG_CP_MV_AS 7
|
#define MSG_CP_MV_AS 7
|
||||||
#define MSG_CUR_SEL_OPTS 8
|
#define MSG_CUR_SEL_OPTS 8
|
||||||
#define MSG_FORCE_RM 9
|
#define MSG_FORCE_RM 9
|
||||||
#define MSG_LIMIT 10
|
#define MSG_SIZE_LIMIT 10
|
||||||
#define MSG_NEW_OPTS 11
|
#define MSG_NEW_OPTS 11
|
||||||
#define MSG_CLI_MODE 12
|
#define MSG_CLI_MODE 12
|
||||||
#define MSG_OVERWRITE 13
|
#define MSG_OVERWRITE 13
|
||||||
|
@ -619,6 +619,7 @@ static char * const utils[] = {
|
||||||
#define MSG_NOCHANGE 41
|
#define MSG_NOCHANGE 41
|
||||||
#define MSG_DIR_CHANGED 42
|
#define MSG_DIR_CHANGED 42
|
||||||
#define MSG_BM_NAME 43
|
#define MSG_BM_NAME 43
|
||||||
|
#define MSG_FILE_LIMIT 44
|
||||||
|
|
||||||
static const char * const messages[] = {
|
static const char * const messages[] = {
|
||||||
"",
|
"",
|
||||||
|
@ -631,7 +632,7 @@ static const char * const messages[] = {
|
||||||
"'c'p/'m'v as?",
|
"'c'p/'m'v as?",
|
||||||
"'c'urrent/'s'el?",
|
"'c'urrent/'s'el?",
|
||||||
"%s %s? [Esc cancels]",
|
"%s %s? [Esc cancels]",
|
||||||
"limit exceeded",
|
"size limit exceeded",
|
||||||
"'f'ile/'d'ir/'s'ym/'h'ard?",
|
"'f'ile/'d'ir/'s'ym/'h'ard?",
|
||||||
"'c'li/'g'ui?",
|
"'c'li/'g'ui?",
|
||||||
"overwrite?",
|
"overwrite?",
|
||||||
|
@ -665,6 +666,7 @@ static const char * const messages[] = {
|
||||||
"unchanged",
|
"unchanged",
|
||||||
"dir changed, range sel off",
|
"dir changed, range sel off",
|
||||||
"name: ",
|
"name: ",
|
||||||
|
"file limit exceeded",
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Supported configuration environment variables */
|
/* Supported configuration environment variables */
|
||||||
|
@ -7940,7 +7942,7 @@ static char *load_input(int fd, const char *path)
|
||||||
} else
|
} else
|
||||||
xstrsncpy(cwd, path, PATH_MAX);
|
xstrsncpy(cwd, path, PATH_MAX);
|
||||||
|
|
||||||
while (chunk_count < 512) {
|
while ((chunk_count) < 512 && !msgnum) {
|
||||||
input_read = read(fd, input + total_read, chunk);
|
input_read = read(fd, input + total_read, chunk);
|
||||||
if (input_read < 0) {
|
if (input_read < 0) {
|
||||||
DPRINTF_S(strerror(errno));
|
DPRINTF_S(strerror(errno));
|
||||||
|
@ -7964,8 +7966,8 @@ static char *load_input(int fd, const char *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entries == LIST_FILES_MAX) {
|
if (entries == LIST_FILES_MAX) {
|
||||||
msgnum = MSG_LIMIT;
|
msgnum = MSG_FILE_LIMIT;
|
||||||
goto malloc_1;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
offsets[entries++] = off;
|
offsets[entries++] = off;
|
||||||
|
@ -7973,8 +7975,8 @@ static char *load_input(int fd, const char *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chunk_count == 512) {
|
if (chunk_count == 512) {
|
||||||
msgnum = MSG_LIMIT;
|
msgnum = MSG_SIZE_LIMIT;
|
||||||
goto malloc_1;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We don't need to allocate another chunk */
|
/* We don't need to allocate another chunk */
|
||||||
|
@ -7990,13 +7992,17 @@ static char *load_input(int fd, const char *path)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (off != total_read) {
|
/* Read off the extra data if limits exceeded */
|
||||||
if (entries == LIST_FILES_MAX) {
|
if (msgnum) {
|
||||||
msgnum = MSG_LIMIT;
|
char buf[512];
|
||||||
goto malloc_1;
|
while (read(fd, buf, 512) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
offsets[entries++] = off;
|
if (off != total_read) {
|
||||||
|
if (entries == LIST_FILES_MAX)
|
||||||
|
msgnum = MSG_FILE_LIMIT;
|
||||||
|
else
|
||||||
|
offsets[entries++] = off;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINTF_D(entries);
|
DPRINTF_D(entries);
|
||||||
|
@ -8057,12 +8063,14 @@ malloc_2:
|
||||||
for (i = entries - 1; i >= 0; --i)
|
for (i = entries - 1; i >= 0; --i)
|
||||||
free(paths[i]);
|
free(paths[i]);
|
||||||
malloc_1:
|
malloc_1:
|
||||||
if (msgnum) {
|
if (msgnum) { /* Check if we are past init stage and show msg */
|
||||||
if (home) { /* We are past init stage */
|
if (home) {
|
||||||
printmsg(messages[msgnum]);
|
printmsg(messages[msgnum]);
|
||||||
xdelay(XDELAY_INTERVAL_MS);
|
xdelay(XDELAY_INTERVAL_MS << 2);
|
||||||
} else
|
} else {
|
||||||
msg(messages[msgnum]);
|
msg(messages[msgnum]);
|
||||||
|
usleep(XDELAY_INTERVAL_MS << 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
free(input);
|
free(input);
|
||||||
free(paths);
|
free(paths);
|
||||||
|
|
Loading…
Reference in a new issue