From 9dd7a1b6250fea48dfc8901afabf7845a3487eff Mon Sep 17 00:00:00 2001 From: haranp Date: Sun, 17 Dec 2006 09:48:33 +0000 Subject: Let scorefile be '-' for reading from standard input, following Shawn Moore's request in 1617269. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@648 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/hiscores.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'crawl-ref/source/hiscores.cc') diff --git a/crawl-ref/source/hiscores.cc b/crawl-ref/source/hiscores.cc index 8ebe79f1c6..da3061564c 100644 --- a/crawl-ref/source/hiscores.cc +++ b/crawl-ref/source/hiscores.cc @@ -418,6 +418,10 @@ static bool unlock_file_handle( FILE *handle ) FILE *hs_open( const char *mode, const std::string &scores ) { + // allow reading from standard input + if ( scores == "-" ) + return stdin; + FILE *handle = fopen(scores.c_str(), mode); #ifdef SHARED_FILES_CHMOD_PUBLIC chmod(scores.c_str(), SHARED_FILES_CHMOD_PUBLIC); @@ -442,7 +446,7 @@ void hs_close( FILE *handle, const char *mode, const std::string &scores ) { UNUSED( mode ); - if (handle == NULL) + if (handle == NULL || handle == stdin) return; #ifdef USE_FILE_LOCKING -- cgit v1.2.3-54-g00ecf