diff options
author | Rob Savoye | 2010-11-28 13:14:04 -0700 |
---|---|---|
committer | Rob Savoye | 2010-11-28 13:14:04 -0700 |
commit | b68acf9988c51bc8afb91ab80569aad89b70d4dc (patch) | |
tree | 77c9e8594a8a564709537df85ab3acfe274db816 /gr-run-waveform | |
parent | 678f405e3abcdae357a1b583d94bf2005a3bbdc0 (diff) | |
download | gnuradio-b68acf9988c51bc8afb91ab80569aad89b70d4dc.tar.gz gnuradio-b68acf9988c51bc8afb91ab80569aad89b70d4dc.tar.bz2 gnuradio-b68acf9988c51bc8afb91ab80569aad89b70d4dc.zip |
fix xyzzy_file_exists() and test case
Diffstat (limited to 'gr-run-waveform')
-rw-r--r-- | gr-run-waveform/test_xyzzy.cc | 16 | ||||
-rw-r--r-- | gr-run-waveform/xyzzy.cc | 21 |
2 files changed, 24 insertions, 13 deletions
diff --git a/gr-run-waveform/test_xyzzy.cc b/gr-run-waveform/test_xyzzy.cc index b6497432a..4a3756d41 100644 --- a/gr-run-waveform/test_xyzzy.cc +++ b/gr-run-waveform/test_xyzzy.cc @@ -122,18 +122,30 @@ main(int argc, char *argv[]) // Does a file with name 'filename' exist in magic filesystem? if (xyzzy_file_exists("srfi/srfi-35.scm")) { + cout << "FAILED: xyzzy_file_exists()" << endl; + } else { + cout << "PASSED: xyzzy_file_exists()" << endl; + } + + // Does a file with name 'filename' exist in magic filesystem? + if (xyzzy_file_exists("/-xyzzy-/srfi/srfi-35.scm")) { cout << "PASSED: xyzzy_file_exists()" << endl; } else { cout << "FAILED: xyzzy_file_exists()" << endl; - } + } + +// xyzzy_file_exists("abcd.scm") -> always false +// xyzzy_file_exists("/-xyzzy-/abcd.scm") -> depends on whether "abcd.scm" is in // Return a C port that will read the file contents - +#if 0 if (xyzzy_make_read_only_port("gnuradio")) { cout << "PASSED: xyzzy_make_read_only_port()" << endl; } else { cout << "FAILED: xyzzy_make_read_only_port()" << endl; } + +#endif scm_boot_guile (argc, argv, inner_main, 0); } diff --git a/gr-run-waveform/xyzzy.cc b/gr-run-waveform/xyzzy.cc index 059edbe08..6179fa5ab 100644 --- a/gr-run-waveform/xyzzy.cc +++ b/gr-run-waveform/xyzzy.cc @@ -115,10 +115,14 @@ XYZZY::init(const std::string &file) bool XYZZY::file_exists(const std::string &filespec) { - std::map<std::string, std::string>::iterator it; - it = _contents.find(filespec); - if (it != _contents.end()) { - return true; + if (filespec.substr(0, 9) == "/-xyzzy-/") { + // look for prefix + std::map<std::string, std::string>::iterator it; + it = _contents.find(filespec.substr(9, filespec.size())); + if (it != _contents.end()) { + return true; + } + return false; } return false; } @@ -128,15 +132,10 @@ XYZZY::file_exists(const std::string &filespec) SCM XYZZY::make_read_only_port(const std::string &filespec) { -#if 0 - char *filename = const_cast<char *>(filespec.c_str()); - _portbits = scm_make_port_type(filename, xyzzy_fill_input, xyzzy_write); + _portbits = scm_make_port_type(const_cast<char *>(filespec.c_str()), + xyzzy_fill_input, xyzzy_write); scm_set_port_flush (_portbits, xyzzy_flush); scm_set_port_close (_portbits, xyzzy_close); -#else - SCM result; - return result; -#endif } string |