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

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 7月 28日 (水) 23:43:08 JST


Revision: 3956
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=3956
Author:   yutakapon
Date:     2010-07-28 23:43:08 +0900 (Wed, 28 Jul 2010)

Log Message:
-----------
マクロコマンド filetruncate を追加した。

とりあえず、helpid.h の番号は従来のルール通りに採番したため、ttmparse.h の値とは異なる。

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/filetruncate.html
    trunk/doc/ja/html/macro/command/filetruncate.html


-------------- next part --------------
Added: trunk/doc/en/html/macro/command/filetruncate.html
===================================================================
--- trunk/doc/en/html/macro/command/filetruncate.html	                        (rev 0)
+++ trunk/doc/en/html/macro/command/filetruncate.html	2010-07-28 14:43:08 UTC (rev 3956)
@@ -0,0 +1,48 @@
+<!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>filetruncate</title>
+  <meta http-equiv="Content-Style-Type" content="text/css">
+  <link rel="stylesheet" href="../../style.css" type="text/css">
+</head>
+
+<body>
+
+
+<h1>filetruncate</h1>
+
+<p>
+Changes the size of a file.
+</p>
+
+<pre class="macro-syntax">
+filetruncate &lt;filename&gt; &lt;size&gt;
+</pre>
+
+<h2>Remarks</h2>
+
+<p>
+Changes the &lt;size&gt; bytes of a &lt;filename&gt; file.<br>
+Null characters('\0') are appended if the file is extended.<br>
+<br>
+
+The system variable "result" value is set to 0 if the file size is successfully changed. 
+The system variable "result" value of -1 indicates an error.
+</p>
+
+<h2>Example</h2>
+
+<pre class="macro-example">
+filetruncate 'test.exe' 32
+
+if result = -1 then
+	messagebox 'file truncate error' 'filetruncate'
+else
+	messagebox 'file truncate success' 'filetruncate'
+endif
+</pre>
+
+</body>
+</html>

Modified: trunk/doc/en/html/macro/command/index.html
===================================================================
--- trunk/doc/en/html/macro/command/index.html	2010-07-28 04:59:12 UTC (rev 3955)
+++ trunk/doc/en/html/macro/command/index.html	2010-07-28 14:43:08 UTC (rev 3956)
@@ -140,6 +140,7 @@
  <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="filetruncate.html">filetruncate</a> (version 4.67 or later)
  <li><a href="filewrite.html">filewrite</a>
  <li><a href="filewriteln.html">filewriteln</a>
  <li><a href="findoperations.html">findfirst, findnext, findclose</a>

Modified: trunk/doc/en/teraterm.hhc
===================================================================
--- trunk/doc/en/teraterm.hhc	2010-07-28 04:59:12 UTC (rev 3955)
+++ trunk/doc/en/teraterm.hhc	2010-07-28 14:43:08 UTC (rev 3956)
@@ -1132,6 +1132,11 @@
 					<param name="ImageNumber" value="11">
 					</OBJECT>
 				<LI> <OBJECT type="text/sitemap">
+					<param name="Name" value="filetruncate">
+					<param name="Local" value="html\macro\command\filetruncate.html">
+					<param name="ImageNumber" value="11">
+					</OBJECT>
+				<LI> <OBJECT type="text/sitemap">
 					<param name="Name" value="filewrite">
 					<param name="Local" value="html\macro\command\filewrite.html">
 					<param name="ImageNumber" value="11">

Modified: trunk/doc/en/teraterm.hhp
===================================================================
--- trunk/doc/en/teraterm.hhp	2010-07-28 04:59:12 UTC (rev 3955)
+++ trunk/doc/en/teraterm.hhp	2010-07-28 14:43:08 UTC (rev 3956)
@@ -193,6 +193,7 @@
 HlpMacroCommandFilestat=html\macro\command\filestat.html
 HlpMacroCommandFilestrseek=html\macro\command\filestrseek.html
 HlpMacroCommandFilestrseek2=html\macro\command\filestrseek2.html
+HlpMacroCommandFiletruncate=html\macro\command\filetruncate.html
 HlpMacroCommandFilewrite=html\macro\command\filewrite.html
 HlpMacroCommandFilewriteln=html\macro\command\filewriteln.html
 HlpMacroCommandFindoperations=html\macro\command\findoperations.html

Added: trunk/doc/ja/html/macro/command/filetruncate.html
===================================================================
--- trunk/doc/ja/html/macro/command/filetruncate.html	                        (rev 0)
+++ trunk/doc/ja/html/macro/command/filetruncate.html	2010-07-28 14:43:08 UTC (rev 3956)
@@ -0,0 +1,47 @@
+<!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>filetruncate</title>
+  <meta http-equiv="Content-Style-Type" content="text/css">
+  <link rel="stylesheet" href="../../style.css" type="text/css">
+</head>
+
+<body>
+
+
+<h1>filetruncate</h1>
+
+<p>
+ƒtƒ@ƒCƒ‹‚̃TƒCƒY‚ð•ÏX‚·‚éB
+</p>
+
+<pre class="macro-syntax">
+filetruncate &lt;filename&gt; &lt;size&gt;
+</pre>
+
+<h2>‰ðà</h2>
+
+<p>
+ƒtƒ@ƒCƒ‹ &lt;filename&gt; ‚ðƒTƒCƒY &lt;size&gt; ƒoƒCƒg‚Ì‘å‚«‚³‚ɕύX‚·‚éB<br>
+Žw’肵‚½ƒTƒCƒY‚ªAŠù‘¶‚Ì‘å‚«‚³‚ð’´‚¦‚½ê‡Aƒkƒ‹•¶Žš('\0')‚ª’ljÁ‚³‚ê‚éB<br>
+<br>
+
+ƒTƒCƒY•ÏX‚ɐ¬Œ÷‚µ‚½ê‡‚́Aresult •Ï”‚É 0 ‚ªŠi”[‚³‚ê‚éBŽ¸”s‚µ‚½ê‡‚Í -1 ‚ªŠi”[‚³‚ê‚éB
+</p>
+
+<h2>—á</h2>
+
+<pre class="macro-example">
+filetruncate 'test.exe' 32
+
+if result = -1 then
+	messagebox 'file truncate error' 'filetruncate'
+else
+	messagebox 'file truncate success' 'filetruncate'
+endif
+</pre>
+
+</body>
+</html>

Modified: trunk/doc/ja/html/macro/command/index.html
===================================================================
--- trunk/doc/ja/html/macro/command/index.html	2010-07-28 04:59:12 UTC (rev 3955)
+++ trunk/doc/ja/html/macro/command/index.html	2010-07-28 14:43:08 UTC (rev 3956)
@@ -140,6 +140,7 @@
  <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="filetruncate.html">filetruncate</a> (ƒo[ƒWƒ‡ƒ“4.67ˆÈ~)
  <li><a href="filewrite.html">filewrite</a>
  <li><a href="filewriteln.html">filewriteln</a>
  <li><a href="findoperations.html">findfirst, findnext, findclose</a>

Modified: trunk/doc/ja/teraterm.hhc
===================================================================
--- trunk/doc/ja/teraterm.hhc	2010-07-28 04:59:12 UTC (rev 3955)
+++ trunk/doc/ja/teraterm.hhc	2010-07-28 14:43:08 UTC (rev 3956)
@@ -1141,6 +1141,10 @@
 					<param name="ImageNumber" value="11">
 					</OBJECT>
 				<LI> <OBJECT type="text/sitemap">
+					<param name="Name" value="filetruncate">
+					<param name="Local" value="html\macro\command\filetruncate.html">
+					</OBJECT>
+				<LI> <OBJECT type="text/sitemap">
 					<param name="Name" value="filewrite">
 					<param name="Local" value="html\macro\command\filewrite.html">
 					<param name="ImageNumber" value="11">

Modified: trunk/doc/ja/teraterm.hhp
===================================================================
--- trunk/doc/ja/teraterm.hhp	2010-07-28 04:59:12 UTC (rev 3955)
+++ trunk/doc/ja/teraterm.hhp	2010-07-28 14:43:08 UTC (rev 3956)
@@ -203,6 +203,7 @@
 HlpMacroCommandFilestat=html\macro\command\filestat.html
 HlpMacroCommandFilestrseek=html\macro\command\filestrseek.html
 HlpMacroCommandFilestrseek2=html\macro\command\filestrseek2.html
+HlpMacroCommandFiletruncate=html\macro\command\filetruncate.html
 HlpMacroCommandFilewrite=html\macro\command\filewrite.html
 HlpMacroCommandFilewriteln=html\macro\command\filewriteln.html
 HlpMacroCommandFindoperations=html\macro\command\findoperations.html

Modified: trunk/teraterm/common/helpid.h
===================================================================
--- trunk/teraterm/common/helpid.h	2010-07-28 04:59:12 UTC (rev 3955)
+++ trunk/teraterm/common/helpid.h	2010-07-28 14:43:08 UTC (rev 3956)
@@ -202,6 +202,7 @@
 #define HlpMacroCommandFilestat         92178
 #define HlpMacroCommandFilestrseek      92034
 #define HlpMacroCommandFilestrseek2     92035
+#define HlpMacroCommandFiletruncate     92179
 #define HlpMacroCommandFilewrite        92036
 #define HlpMacroCommandFilewriteln      92037
 #define HlpMacroCommandFindoperations   92039

Modified: trunk/teraterm/ttpmacro/ttl.c
===================================================================
--- trunk/teraterm/ttpmacro/ttl.c	2010-07-28 04:59:12 UTC (rev 3955)
+++ trunk/teraterm/ttpmacro/ttl.c	2010-07-28 14:43:08 UTC (rev 3956)
@@ -21,6 +21,11 @@
 #include "tttypes.h"
 #include <shellapi.h>
 #include <sys/stat.h>
+#include <io.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <share.h>
 
 // Oniguruma: Regular expression library
 #define ONIG_EXTERN extern
@@ -1506,6 +1511,58 @@
 	return Err;
 }
 
+WORD TTLFileTruncate()
+{
+	WORD Err;
+	TStrVal FName;
+	int result = -1;
+	int TruncByte;
+	int fh = -1;
+	int ret;
+
+	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;
+	}
+
+	if (CheckParameterGiven()) { 
+		GetIntVal(&TruncByte,&Err);
+		if (Err!=0) return Err;
+	} else {
+		Err = ErrSyntax;
+		goto end;
+	}
+
+	// ƒtƒ@ƒCƒ‹‚ðŽw’肵‚½ƒTƒCƒY‚Ő؂è‹l‚ß‚éB
+   ret = _sopen_s( &fh, FName, _O_RDWR | _O_CREAT, _SH_DENYNO, _S_IREAD | _S_IWRITE );
+   if (ret != 0) {
+		Err = ErrCantOpen;
+		goto end;
+   }
+   ret = _chsize_s(fh, TruncByte);
+   if (ret != 0) {
+		Err = ErrInvalidCtl;
+		goto end;
+   }
+
+	result = 0;
+	Err = 0;
+
+end:
+	SetResult(result);
+
+	if (fh != -1)
+		_close(fh);
+
+	return Err;
+}
+
 WORD TTLFileWrite()
 {
 	WORD Err;
@@ -3958,6 +4015,8 @@
 			Err = TTLFileStrSeek(); break;
 		case RsvFileStrSeek2:
 			Err = TTLFileStrSeek2(); break;
+		case RsvFileTruncate:
+			Err = TTLFileTruncate(); break;
 		case RsvFileWrite:
 			Err = TTLFileWrite(); break;
 		case RsvFileWriteLn:

Modified: trunk/teraterm/ttpmacro/ttmparse.c
===================================================================
--- trunk/teraterm/ttpmacro/ttmparse.c	2010-07-28 04:59:12 UTC (rev 3955)
+++ trunk/teraterm/ttpmacro/ttmparse.c	2010-07-28 14:43:08 UTC (rev 3956)
@@ -181,6 +181,7 @@
 		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,"filetruncate")==0) *WordId = RsvFileTruncate;
 		else if (_stricmp(Str,"filewrite")==0) *WordId = RsvFileWrite;
 		else if (_stricmp(Str,"filewriteln")==0) *WordId = RsvFileWriteLn;
 		else if (_stricmp(Str,"findclose")==0) *WordId = RsvFindClose;

Modified: trunk/teraterm/ttpmacro/ttmparse.h
===================================================================
--- trunk/teraterm/ttpmacro/ttmparse.h	2010-07-28 04:59:12 UTC (rev 3955)
+++ trunk/teraterm/ttpmacro/ttmparse.h	2010-07-28 14:43:08 UTC (rev 3956)
@@ -195,6 +195,7 @@
 #define RsvYmodemRecv   152
 #define RsvYmodemSend   153
 #define RsvFileStat     154
+#define RsvFileTruncate 155
 
 #define RsvOperator     200
 #define RsvBNot         201



Ttssh2-commit メーリングリストの案内
Back to archive index