April 18, 2006
用Beyond Compare同步网站更新
Beyond Compare 是非常好用的文件夹/文件比较/合并工具。在文件夹比较的功能上,有订制比较方式,文件过滤的功能。现在的版本开始支持Ftp,于是想到用它来同步网站。也就是说本地的开发修改,使用Beyond Compare通过Ftp上传到服务器上。
遇到的问题就是如何进行本地/服务器文件的比较。
文件上传到服务器,ftp服务器端显示的修改时间(Data Modified)实际上是文件上传时间,所以比较修改时间不可靠。
于是想到去比较文件的size,但是发现虽然是同一个html文件,本地和服务器端的大小却不一样。在Google group 上找到了答案。原因是以ascii方式上传unix系统ftp时,对换行符处理造成的。Dos(Windows)中的换行符“\r\n”被自动替换成了“\n”。相差的字节数基本上就是文件的行数。binary方式的话没有这个问题。
What is a newline in UNIX is a combination of a linefeed and a carriage
return in DOS. This gets transformed in ftp with an ascii transfer.
The binary transfer does not make this translation. When you “type” the
file, what is normally a new line begins directly below the end of the
preceeding line. The UNIX newline becomes a DOS linefeed without the
carriage return. The file size is the same, but it looks funny.If you do a “wc -l” on the UNIX file. The number of lines that it shows
should be the same as the difference in the file sizes.Bob
所以,BC中选择使用Binary mode来进行Ftp传输,仅通过File size来比较文件,基本上可以满足要求了。
Filed by
charlie
at 7:05 am under Engineer, Tools
No Comments
1 Comment

