我试图将一个小型数据分析程序从64位UNIX移植到32位Windows XP系统(不要问:)).但是现在我遇到了2GB文件大小限制的问题(在这个平台上长时间不是64位).
我搜索了这个网站和其他人可能的解决方案,但找不到任何可以直接翻译我的问题.问题在于使用fseek和ftell.
有没有人知道对以下两个函数的修改,使它们可以在32位Windows XP上运行大于2GB的文件(实际上是100GB).
至关重要的是,nsamples的返回类型是64位整数(可能是int64_t).
long nsamples(char* filename)
{
FILE *fp;
long n;
/* Open file */
fp = fopen(filename, "rb");
/* Find end of file */
fseek(fp, 0L, SEEK_END);
/* Get number of samples */
n = ftell(fp) / sizeof(short);
/* Close file */
fclose(fp);
/* Return number of samples in file */
return n;
}
Run Code Online (Sandbox Code Playgroud)
和
void readdata(char* filename, short* data, long start, int n)
{
FILE *fp;
/* Open file */
fp = fopen(filename, "rb");
/* …Run Code Online (Sandbox Code Playgroud) 我在RoR教程的第6章中似乎无法使命令'tail -f log/development.log'起作用.使用Mac OS X 10.6.6,Ruby 1.9.2,Rails 3.0.3和RVM.我正试图在一个sanboxed Rails控制台中运行它,这是正在发生的事情的输出:
Trenton-Scotts-MacBook-Air:sample_app TTS$ rails c --sandbox
Loading development environment in sandbox (Rails 3.0.3)
Any modifications you make will be rolled back on exit
ruby-1.9.2-p136 :001 > tail -f log/development.log
SyntaxError: (irb):1: syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '('
tail -f log/development.log
^
from /Users/TTS/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/commands/console.rb:44:in `start'
from /Users/TTS/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/commands/console.rb:8:in `start'
from /Users/TTS/.rvm/gems/ruby-1.9.2-p136/gems/railties-3.0.3/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
ruby-1.9.2-p136 :002 >
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?
我希望创建一个控制台应用程序,该应用程序将读取文件并监视每行的新行,因为每隔0.5秒它就会被另一个进程写入。
在使用.NET 4.5的控制台应用程序中如何实现?
我需要只读取文件的最后一行,而不使用File:ReadBackwards模块,因为它没有安装在我需要执行脚本的远程服务器(windows)上.请建议最有效的方法来只读最后一行.