aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2002-12-14 15:24:03 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2002-12-14 15:24:03 +0000
commit4a9e9df2958296dcfef8289390d6939dcab79830 (patch)
tree67d6a2d3ae7e79980192a16069f32874742e67a4
parent[w3m-dev 03568] Re: preserve timestamp (diff)
downloadw3m-4a9e9df2958296dcfef8289390d6939dcab79830.tar.gz
w3m-4a9e9df2958296dcfef8289390d6939dcab79830.zip
[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>
-rw-r--r--ChangeLog12
-rw-r--r--file.c31
-rw-r--r--fm.h3
-rw-r--r--rc.c6
4 files changed, 36 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 3e9a563..4948225 100644
--- 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
@@ -5848,4 +5858,4 @@ a * [w3m-dev 03276] compile error on EWS4800
* release-0-2-1
* import w3m-0.2.1
-$Id: ChangeLog,v 1.619 2002/12/14 15:18:37 ukai Exp $
+$Id: ChangeLog,v 1.620 2002/12/14 15:24:03 ukai Exp $
diff --git a/file.c b/file.c
index 29d994b..50ca6c2 100644
--- a/file.c
+++ b/file.c
@@ -1,4 +1,4 @@
-/* $Id: file.c,v 1.160 2002/12/14 15:18:38 ukai Exp $ */
+/* $Id: file.c,v 1.161 2002/12/14 15:24:03 ukai Exp $ */
#include "fm.h"
#include <sys/types.h>
#include "myctype.h"
@@ -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
index 3d4f397..22b2ad0 100644
--- a/fm.h
+++ b/fm.h
@@ -1,4 +1,4 @@
-/* $Id: fm.h,v 1.96 2002/12/11 15:07:53 ukai Exp $ */
+/* $Id: fm.h,v 1.97 2002/12/14 15:24:04 ukai Exp $ */
/*
* w3m: WWW wo Miru utility
*
@@ -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
index 6ce1b55..9b39e61 100644
--- a/rc.c
+++ b/rc.c
@@ -1,4 +1,4 @@
-/* $Id: rc.c,v 1.70 2002/12/06 16:50:34 ukai Exp $ */
+/* $Id: rc.c,v 1.71 2002/12/14 15:24:04 ukai Exp $ */
/*
* Initialization file etc.
*/
@@ -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},