[Ttssh2-commit] [3846] マクロコマンド filestat を追加した。

svnno****@sourc***** svnno****@sourc*****
2010年 4月 7日 (水) 21:09:19 JST


Revision: 3846
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=3846
Author:   yutakapon
Date:     2010-04-07 21:09:19 +0900 (Wed, 07 Apr 2010)

Log Message:
-----------
マクロコマンド filestat を追加した。
cf.
http://logmett.com/forum/viewtopic.php?f=6&t=1357

Modified Paths:
--------------
    trunk/doc/en/html/macro/command/index.html
    trunk/doc/en/teraterm.hhc
    trunk/doc/en/teraterm.hhp
    trunk/doc/ja/html/macro/command/index.html
    trunk/doc/ja/teraterm.hhc
    trunk/doc/ja/teraterm.hhp
    trunk/teraterm/common/helpid.h
    trunk/teraterm/ttpmacro/ttl.c
    trunk/teraterm/ttpmacro/ttmparse.c
    trunk/teraterm/ttpmacro/ttmparse.h

Added Paths:
-----------
    trunk/doc/en/html/macro/command/filestat.html
    trunk/doc/ja/html/macro/command/filestat.html


-------------- next part --------------
Added: trunk/doc/en/html/macro/command/filestat.html
===================================================================
--- trunk/doc/en/html/macro/command/filestat.html	                        (rev 0)
+++ trunk/doc/en/html/macro/command/filestat.html	2010-04-07 12:09:19 UTC (rev 3846)
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+  "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+  <title>filestat</title>
+  <meta http-equiv="Content-Style-Type" content="text/css">
+  <link rel="stylesheet" href="../../style.css" type="text/css">
+</head>
+
+<body>
+
+
+<h1>filestat</h1>
+
+<p>
+Gets status information on a file.
+</p>
+
+<pre class="macro-syntax">
+filestat &lt;filename&gt; &lt;size&gt; [&lt;mtime&gt;] [&lt;drive&gt;] 
+</pre>
+
+<h2>Remarks</h2>
+
+<p>
+Obtains information about the file or directory specified by &lt;filename&gt;.<br>
+&lt;size&gt; is set to the size of the file in bytes.
+&lt;mtime&gt; is set to the time of last modification of file.
+&lt;drive&gt; is set to the drive number of the disk containing the file.
+<br>
+The system variable "result" value of -1 indicates an error.
+</p>
+
+<h2>Example</h2>
+
+<pre class="macro-example">
+filestat 'test.exe' size time drive
+
+if result = -1 then
+	messagebox 'file open error' 'filestat'
+else
+	sprintf2 str 'File size=%d Time modified=%d Drive=%d' size time drive
+	messagebox str 'filestat'
+endif
+</pre>
+
+</body>
+</html>

Modified: trunk/doc/en/html/macro/command/index.html
===================================================================
--- trunk/doc/en/html/macro/command/index.html	2010-04-07 11:59:19 UTC (rev 3845)
+++ trunk/doc/en/html/macro/command/index.html	2010-04-07 12:09:19 UTC (rev 3846)
@@ -137,6 +137,7 @@
  <li><a href="filesearch.html">filesearch</a>
  <li><a href="fileseek.html">fileseek</a>
  <li><a href="fileseekback.html">fileseekback</a>
+ <li><a href="filestat.html">filestat</a> (version 4.66 or later)
  <li><a href="filestrseek.html">filestrseek</a>
  <li><a href="filestrseek2.html">filestrseek2</a>
  <li><a href="filewrite.html">filewrite</a>

Modified: trunk/doc/en/teraterm.hhc
===================================================================
--- trunk/doc/en/teraterm.hhc	2010-04-07 11:59:19 UTC (rev 3845)
+++ trunk/doc/en/teraterm.hhc	2010-04-07 12:09:19 UTC (rev 3846)
@@ -1117,6 +1117,11 @@
 					<param name="ImageNumber" value="11">
 					</OBJECT>
 				<LI> <OBJECT type="text/sitemap">
+					<param name="Name" value="filestat">
+					<param name="Local" value="html\macro\command\filestat.html">
+					<param name="ImageNumber" value="11">
+					</OBJECT>
+				<LI> <OBJECT type="text/sitemap">
 					<param name="Name" value="filestrseek">
 					<param name="Local" value="html\macro\command\filestrseek.html">
 					<param name="ImageNumber" value="11">

Modified: trunk/doc/en/teraterm.hhp
===================================================================
--- trunk/doc/en/teraterm.hhp	2010-04-07 11:59:19 UTC (rev 3845)
+++ trunk/doc/en/teraterm.hhp	2010-04-07 12:09:19 UTC (rev 3846)
@@ -190,6 +190,7 @@
 HlpMacroCommandFilesearch=html\macro\command\filesearch.html
 HlpMacroCommandFileseek=html\macro\command\fileseek.html
 HlpMacroCommandFileseekback=html\macro\command\fileseekback.html
+HlpMacroCommandFilestat=html\macro\command\filestat.html
 HlpMacroCommandFilestrseek=html\macro\command\filestrseek.html
 HlpMacroCommandFilestrseek2=html\macro\command\filestrseek2.html
 HlpMacroCommandFilewrite=html\macro\command\filewrite.html

Added: trunk/doc/ja/html/macro/command/filestat.html
===================================================================
--- trunk/doc/ja/html/macro/command/filestat.html	                        (rev 0)
+++ trunk/doc/ja/html/macro/command/filestat.html	2010-04-07 12:09:19 UTC (rev 3846)
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+  "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
+  <title>filestat</title>
+  <meta http-equiv="Content-Style-Type" content="text/css">
+  <link rel="stylesheet" href="../../style.css" type="text/css">
+</head>
+
+<body>
+
+
+<h1>filestat</h1>
+
+<p>
+ƒtƒ@ƒCƒ‹‚Ì“Œvî•ñ‚ðŽæ“¾‚·‚éB
+</p>
+
+<pre class="macro-syntax">
+filestat &lt;filename&gt; &lt;size&gt; [&lt;mtime&gt;] [&lt;drive&gt;] 
+</pre>
+
+<h2>‰ðà</h2>
+
+<p>
+ƒtƒ@ƒCƒ‹ &lt;filename&gt; ‚Ì“Œvî•ñ‚ðŽæ“¾‚·‚éB<br>
+ƒtƒ@ƒCƒ‹ƒTƒCƒY‚ð &lt;size&gt; AÅI•ÏXŽžŠÔ‚ð &lt;mtime&gt; Aƒhƒ‰ƒCƒu”ԍ†‚ð &lt;drive&gt; ‚ÉŠi”[‚·‚éB<br>
+Žæ“¾‚ÉŽ¸”s‚µ‚½ê‡‚́Aresult •Ï”‚É -1 ‚ªŠi”[‚³‚ê‚éB
+</p>
+
+<h2>—á</h2>
+
+<pre class="macro-example">
+filestat 'test.exe' size time drive
+
+if result = -1 then
+	messagebox 'file open error' 'filestat'
+else
+	sprintf2 str 'File size=%d Time modified=%d Drive=%d' size time drive
+	messagebox str 'filestat'
+endif
+</pre>
+
+</body>
+</html>

Modified: trunk/doc/ja/html/macro/command/index.html
===================================================================
--- trunk/doc/ja/html/macro/command/index.html	2010-04-07 11:59:19 UTC (rev 3845)
+++ trunk/doc/ja/html/macro/command/index.html	2010-04-07 12:09:19 UTC (rev 3846)
@@ -137,6 +137,7 @@
  <li><a href="filesearch.html">filesearch</a>
  <li><a href="fileseek.html">fileseek</a>
  <li><a href="fileseekback.html">fileseekback</a>
+ <li><a href="filestat.html">filestat</a> (ƒo[ƒWƒ‡ƒ“4.66ˆÈ~)
  <li><a href="filestrseek.html">filestrseek</a>
  <li><a href="filestrseek2.html">filestrseek2</a>
  <li><a href="filewrite.html">filewrite</a>

Modified: trunk/doc/ja/teraterm.hhc
===================================================================
--- trunk/doc/ja/teraterm.hhc	2010-04-07 11:59:19 UTC (rev 3845)
+++ trunk/doc/ja/teraterm.hhc	2010-04-07 12:09:19 UTC (rev 3846)
@@ -1127,6 +1127,10 @@
 					<param name="ImageNumber" value="11">
 					</OBJECT>
 				<LI> <OBJECT type="text/sitemap">
+					<param name="Name" value="filestat">
+					<param name="Local" value="html\macro\command\filestat.html">
+					</OBJECT>
+				<LI> <OBJECT type="text/sitemap">
 					<param name="Name" value="filestrseek">
 					<param name="Local" value="html\macro\command\filestrseek.html">
 					<param name="ImageNumber" value="11">

Modified: trunk/doc/ja/teraterm.hhp
===================================================================
--- trunk/doc/ja/teraterm.hhp	2010-04-07 11:59:19 UTC (rev 3845)
+++ trunk/doc/ja/teraterm.hhp	2010-04-07 12:09:19 UTC (rev 3846)
@@ -200,6 +200,7 @@
 HlpMacroCommandFilesearch=html\macro\command\filesearch.html
 HlpMacroCommandFileseek=html\macro\command\fileseek.html
 HlpMacroCommandFileseekback=html\macro\command\fileseekback.html
+HlpMacroCommandFilestat=html\macro\command\filestat.html
 HlpMacroCommandFilestrseek=html\macro\command\filestrseek.html
 HlpMacroCommandFilestrseek2=html\macro\command\filestrseek2.html
 HlpMacroCommandFilewrite=html\macro\command\filewrite.html

Modified: trunk/teraterm/common/helpid.h
===================================================================
--- trunk/teraterm/common/helpid.h	2010-04-07 11:59:19 UTC (rev 3845)
+++ trunk/teraterm/common/helpid.h	2010-04-07 12:09:19 UTC (rev 3846)
@@ -199,6 +199,7 @@
 #define HlpMacroCommandFilesearch       92031
 #define HlpMacroCommandFileseek         92032
 #define HlpMacroCommandFileseekback     92033
+#define HlpMacroCommandFilestat         92178
 #define HlpMacroCommandFilestrseek      92034
 #define HlpMacroCommandFilestrseek2     92035
 #define HlpMacroCommandFilewrite        92036

Modified: trunk/teraterm/ttpmacro/ttl.c
===================================================================
--- trunk/teraterm/ttpmacro/ttl.c	2010-04-07 11:59:19 UTC (rev 3845)
+++ trunk/teraterm/ttpmacro/ttl.c	2010-04-07 12:09:19 UTC (rev 3846)
@@ -20,6 +20,7 @@
 #include "ttmenc.h"
 #include "tttypes.h"
 #include <shellapi.h>
+#include <sys/stat.h>
 
 // Oniguruma: Regular expression library
 #define ONIG_EXTERN extern
@@ -1359,6 +1360,56 @@
 	return Err;
 }
 
+WORD TTLFileStat()
+{
+	WORD Err, SizeVarId, TimeVarId, DrvVarId;
+	TStrVal FName;
+	struct _stat st;
+	int ret;
+	int result = -1;
+
+	Err = 0;
+	GetStrVal(FName,&Err);
+	if ((Err==0) &&
+	    (strlen(FName)==0))
+		Err = ErrSyntax;
+	if (Err!=0) return Err;
+
+	if (!GetAbsPath(FName,sizeof(FName))) {
+		goto end;
+	}
+
+	ret = _stat(FName, &st);
+	if (ret != 0) {
+		goto end;
+	}
+
+	if (CheckParameterGiven()) { 
+		GetIntVar(&SizeVarId,&Err);
+		if (Err!=0) return Err;
+		SetIntVal(SizeVarId, st.st_size);
+	}
+
+	if (CheckParameterGiven()) { 
+		GetIntVar(&TimeVarId,&Err);
+		if (Err!=0) return Err;
+		SetIntVal(TimeVarId, (int)st.st_mtime);
+	}
+
+	if (CheckParameterGiven()) { 
+		GetIntVar(&DrvVarId,&Err);
+		if (Err!=0) return Err;
+		SetIntVal(DrvVarId, st.st_dev);
+	}
+
+	result = 0;
+
+end:
+	SetResult(result);
+
+	return Err;
+}
+
 WORD TTLFileStrSeek()
 {
 	WORD Err;
@@ -3897,6 +3948,8 @@
 			Err = TTLFileSeek(); break;
 		case RsvFileSeekBack:
 			Err = TTLFileSeekBack(); break;
+		case RsvFileStat:
+			Err = TTLFileStat(); break;
 		case RsvFileStrSeek:
 			Err = TTLFileStrSeek(); break;
 		case RsvFileStrSeek2:

Modified: trunk/teraterm/ttpmacro/ttmparse.c
===================================================================
--- trunk/teraterm/ttpmacro/ttmparse.c	2010-04-07 11:59:19 UTC (rev 3845)
+++ trunk/teraterm/ttpmacro/ttmparse.c	2010-04-07 12:09:19 UTC (rev 3846)
@@ -178,6 +178,7 @@
 		else if (_stricmp(Str,"filesearch")==0) *WordId = RsvFileSearch;
 		else if (_stricmp(Str,"fileseek")==0) *WordId = RsvFileSeek;
 		else if (_stricmp(Str,"fileseekback")==0) *WordId = RsvFileSeekBack;
+		else if (_stricmp(Str,"filestat")==0) *WordId = RsvFileStat;
 		else if (_stricmp(Str,"filestrseek")==0) *WordId = RsvFileStrSeek;
 		else if (_stricmp(Str,"filestrseek2")==0) *WordId = RsvFileStrSeek2;
 		else if (_stricmp(Str,"filewrite")==0) *WordId = RsvFileWrite;

Modified: trunk/teraterm/ttpmacro/ttmparse.h
===================================================================
--- trunk/teraterm/ttpmacro/ttmparse.h	2010-04-07 11:59:19 UTC (rev 3845)
+++ trunk/teraterm/ttpmacro/ttmparse.h	2010-04-07 12:09:19 UTC (rev 3846)
@@ -220,6 +220,7 @@
 
 #define RsvYmodemRecv   176
 #define RsvYmodemSend   177
+#define RsvFileStat     178
 
 // integer type for buffer pointer
 typedef DWORD BINT;



Ttssh2-commit メーリングリストの案内