commit f60cc30e3db6667133f9379871f26c09f0d42395
parent 5d92917eeb6fbebc10115f26a122ecb5cae38e6a
Author: ukai <ukai>
Date: Sat, 14 Dec 2002 15:24:03 +0000
[w3m-dev 03569] Re: preserve timestamp
* file.c (loadGeneralFile): PresetveTimestamp
(_doFileCopy): is_pipe, PreserveTimestamp
(doFileSave): PreserveTImestamp
* fm.h (PreserveTimestamp): added
* rc.c (CMT_PRESERVE_TIMESTAMP): added
(params3): add preserve_timestamp
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
Diffstat:
4 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,3 +1,13 @@
+2002-12-15 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
+
+ * [w3m-dev 03569] Re: preserve timestamp
+ * file.c (loadGeneralFile): PresetveTimestamp
+ (_doFileCopy): is_pipe, PreserveTimestamp
+ (doFileSave): PreserveTImestamp
+ * fm.h (PreserveTimestamp): added
+ * rc.c (CMT_PRESERVE_TIMESTAMP): added
+ (params3): add preserve_timestamp
+
2002-12-15 Takahashi Youichirou <nikuq@hk.airnet.ne.jp>
* [w3m-dev 03568] Re: preserve timestamp
diff --git a/file.c b/file.c
@@ -332,7 +332,8 @@ uncompressed_file_type(char *path, char **ext)
return t0;
}
-static int setModtime(char *path, time_t modtime)
+static int
+setModtime(char *path, time_t modtime)
{
struct utimbuf t;
struct stat st;
@@ -1894,7 +1895,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer,
f.stream = newEncodedStream(f.stream, f.encoding);
if (pu.scheme == SCM_LOCAL) {
struct stat st;
- if (stat(pu.real_file, &st) == 0)
+ if (PreserveTimestamp && !stat(pu.real_file, &st))
f.modtime = st.st_mtime;
file = conv_from_system(guess_save_name(NULL, pu.real_file));
} else
@@ -7378,6 +7379,7 @@ _doFileCopy(char *tmpf, char *defstr, int download)
#endif
struct stat st;
clen_t size = 0;
+ int is_pipe = FALSE;
if (fmInitialized) {
p = searchKeyData();
@@ -7388,7 +7390,9 @@ _doFileCopy(char *tmpf, char *defstr, int download)
return;
p = conv_to_system(q);
}
- if (*p != '|' || !PermitSaveToPipe) {
+ if (*p == '|' && PermitSaveToPipe)
+ is_pipe = TRUE;
+ else {
if (q) {
p = unescape_spaces(Strnew_charp(q))->ptr;
p = conv_to_system(q);
@@ -7428,8 +7432,8 @@ _doFileCopy(char *tmpf, char *defstr, int download)
close_tty();
QuietMessage = TRUE;
fmInitialized = FALSE;
- _MoveFile(tmpf, p);
- if (stat(tmpf, &st) == 0)
+ if (!_MoveFile(tmpf, p) && PreserveTimestamp && !is_pipe &&
+ !stat(tmpf, &st))
setModtime(p, st.st_mtime);
unlink(lock);
exit(0);
@@ -7453,7 +7457,9 @@ _doFileCopy(char *tmpf, char *defstr, int download)
if (*q == '\0')
return;
p = q;
- if (*p != '|' || !PermitSaveToPipe) {
+ if (*p == '|' && PermitSaveToPipe)
+ is_pipe = TRUE;
+ else {
p = expandName(p);
if (checkOverWrite(p) < 0)
return;
@@ -7462,9 +7468,9 @@ _doFileCopy(char *tmpf, char *defstr, int download)
printf("Can't copy. %s and %s are identical.", tmpf, p);
return;
}
- if (_MoveFile(tmpf, p) < 0) {
+ if (_MoveFile(tmpf, p) < 0)
printf("Can't save to %s\n", p);
- } else if (stat(tmpf, &st) == 0)
+ else if (PreserveTimestamp && !is_pipe && !stat(tmpf, &st))
setModtime(p, st.st_mtime);
}
}
@@ -7529,8 +7535,7 @@ doFileSave(URLFile uf, char *defstr)
close_tty();
QuietMessage = TRUE;
fmInitialized = FALSE;
- save2tmp(uf, p);
- if (uf.modtime != -1)
+ if (!save2tmp(uf, p) && PreserveTimestamp && uf.modtime != -1)
setModtime(p, uf.modtime);
UFclose(&uf);
unlink(lock);
@@ -7559,9 +7564,9 @@ doFileSave(URLFile uf, char *defstr)
printf("Can't save. Load file and %s are identical.", p);
return;
}
- if (save2tmp(uf, p) < 0) {
+ if (save2tmp(uf, p) < 0)
printf("Can't save to %s\n", p);
- } else if (uf.modtime != -1)
+ else if (PreserveTimestamp && uf.modtime != -1)
setModtime(p, uf.modtime);
}
}
diff --git a/fm.h b/fm.h
@@ -768,6 +768,7 @@ global char RenderFrame init(FALSE);
global char TargetSelf init(FALSE);
global char PermitSaveToPipe init(FALSE);
global char DecodeCTE init(FALSE);
+global char PreserveTimestamp init(TRUE);
global char ArgvIsURL init(FALSE);
global char MetaRefresh init(FALSE);
diff --git a/rc.c b/rc.c
@@ -167,6 +167,7 @@ static char *config_file = NULL;
#define CMT_RETRY_HTTP "URLに自動的に http:// を補う"
#define CMT_DEFAULT_URL "URLを開く時のデフォルト文字列"
#define CMT_DECODE_CTE "保存時に Content-Transfer-Encoding をデコードする"
+#define CMT_PRESERVE_TIMESTAMP "保存時にタイムスタンプを保持する"
#ifdef USE_MOUSE
#define CMT_MOUSE "マウスを使う"
#define CMT_REVERSE_MOUSE "マウスのドラッグ動作を逆にする"
@@ -322,6 +323,7 @@ static char *config_file = NULL;
#define CMT_RETRY_HTTP "Prepend http:// to URL automatically"
#define CMT_DEFAULT_URL "Default value for open-URL command"
#define CMT_DECODE_CTE "Decode Content-Transfer-Encoding when saving"
+#define CMT_PRESERVE_TIMESTAMP "Preserve timestamp when saving"
#ifdef USE_MOUSE
#define CMT_MOUSE "Enable mouse"
#define CMT_REVERSE_MOUSE "Scroll in reverse direction of mouse drag"
@@ -640,6 +642,8 @@ struct param_ptr params3[] = {
NULL},
{"decode_cte", P_CHARINT, PI_ONOFF, (void *)&DecodeCTE, CMT_DECODE_CTE,
NULL},
+ {"preserve_timestamp", P_CHARINT, PI_ONOFF, (void *)&PreserveTimestamp,
+ CMT_PRESERVE_TIMESTAMP, NULL},
{"keymap_file", P_STRING, PI_TEXT, (void *)&keymap_file, CMT_KEYMAP_FILE,
NULL},
{NULL, 0, 0, NULL, NULL, NULL},