int main(int argc, char **argv)
{
bool debug = false;
+ string re_str;
GetOpt getopt;
getopt.add_option('d', "debug", debug, GetOpt::NO_ARG);
+ getopt.add_argument("regex", re_str, GetOpt::REQUIRED_ARG);
getopt(argc, argv);
- const vector<string> &args = getopt.get_args();
-
- if(args.empty())
- {
- cerr<<"Usage: "<<argv[0]<<" <regex>\n";
- return 1;
- }
-
- Regex regex(args[0]);
+ Regex regex(re_str);
if(debug)
cout<<regex.disassemble();
string line;
{
GetOpt getopt;
getopt.add_option('l', "long", long_format, GetOpt::NO_ARG);
+ getopt.add_argument("file", args, GetOpt::OPTIONAL_ARG);
getopt(argc, argv);
- args = getopt.get_args();
if(args.empty())
args.push_back(".");
}
Z::Z(int argc, char **argv):
input_file(0)
{
+ string input_fn;
GetOpt getopt;
getopt.add_option('d', "decompress", decompress, GetOpt::NO_ARG);
+ getopt.add_argument("filename", input_fn, GetOpt::OPTIONAL_ARG);
getopt(argc, argv);
- const vector<string> &args = getopt.get_args();
- if(!args.empty())
- input_file = new IO::File(args[0]);
+ if(!input_fn.empty())
+ input_file = new IO::File(input_fn);
input = (input_file ? static_cast<IO::Base *>(input_file) : static_cast<IO::Base *>(&IO::cin));
output = &IO::cout;
#include <windows.h>
#include <msp/core/systemerror.h>
-#include <msp/time/units.h>
+#include <msp/time/timedelta.h>
#include "semaphore.h"
namespace Msp {
}
Path get_user_data_dir(const string &)
+{
+ return get_user_data_dir();
+}
+
+Path get_user_data_dir()
{
Android::MainThread *thread = reinterpret_cast<Android::MainThread *>(Application::get_data());
return thread->get_internal_data_path();
return result;
}
-Path get_user_data_dir()
+Path get_sys_conf_dir(const string &)
{
- const string &name = Application::get_name();
- if(name.empty())
- throw logic_error("application name not known");
- return get_user_data_dir(name);
+ return get_sys_conf_dir();
}
-Path get_sys_conf_dir(const string &argv0)
+Path get_sys_conf_dir()
{
- if(argv0.empty())
- throw invalid_argument("get_sys_conf_dir");
+ const char *argv0 = Application::get_argv0();
+ if(!argv0)
+ throw logic_error("no startup command");
Path dir = get_bin_dir(argv0);
return dir;
}
-Path get_sys_conf_dir()
+Path get_sys_data_dir(const string &, const string &)
{
- const char *argv0 = Application::get_argv0();
- if(!argv0)
- throw logic_error("no startup command");
- return get_sys_conf_dir(argv0);
+ return get_sys_data_dir();
}
-Path get_sys_data_dir(const string &argv0, const string &appname)
+Path get_sys_data_dir()
{
- if(argv0.empty() || appname.empty())
- throw invalid_argument("get_sys_data_dir");
+ const char *argv0 = Application::get_argv0();
+ if(!argv0)
+ throw logic_error("no startup command");
Path dir = get_bin_dir(argv0);
if(dir[-1]=="bin" || dir[-1]=="sbin")
- return dir/".."/"share"/appname;
+ return dir/".."/"share"/Application::get_name();
else if(dir[-1]=="MacOS")
return dir/".."/"Resources";
else
return dir;
}
-Path get_sys_data_dir()
+Path get_sys_lib_dir(const string &, const string &)
{
- const char *argv0 = Application::get_argv0();
- if(!argv0)
- throw logic_error("no startup command");
- return get_sys_data_dir(argv0, Application::get_name());
+ return get_sys_lib_dir();
}
-Path get_sys_lib_dir(const string &argv0, const string &appname)
+Path get_sys_lib_dir()
{
- if(argv0.empty() || appname.empty())
- throw invalid_argument("get_sys_lib_dir");
+ const char *argv0 = Application::get_argv0();
+ if(!argv0)
+ throw logic_error("no startup command");
Path dir = get_bin_dir(argv0);
if(dir[-1]=="bin" || dir[-1]=="sbin")
- return dir/".."/"lib"/appname;
+ return dir/".."/"lib"/Application::get_name();
else
return dir;
}
-Path get_sys_lib_dir()
-{
- const char *argv0 = Application::get_argv0();
- if(!argv0)
- throw logic_error("no startup command");
- return get_sys_lib_dir(argv0, Application::get_name());
-}
-
Path path_lookup(const string &name, const list<Path> &paths)
{
for(list<Path>::const_iterator i=paths.begin(); i!=paths.end(); ++i)
+#include <msp/core/application.h>
#include "dir.h"
using namespace std;
return ".";
}
-Path get_user_data_dir(const string &appname)
+Path get_user_data_dir(const string &)
{
+ return get_user_data_dir();
+}
+
+Path get_user_data_dir()
+{
+ const string &appname = Application::get_name();
+ if(appname.empty())
+ throw logic_error("no application name");
+
char buf[1024];
unsigned len = get_application_support_dir(buf, sizeof(buf));
if(len)
#include <cstdlib>
+#include <msp/core/application.h>
#include "dir.h"
using namespace std;
return ".";
}
-Path get_user_data_dir(const string &appname)
+Path get_user_data_dir(const string &)
{
+ return get_user_data_dir();
+}
+
+Path get_user_data_dir()
+{
+ const string &appname = Application::get_name();
if(appname.empty())
- throw invalid_argument("get_user_data_dir");
+ throw logic_error("no application name");
+
return get_home_dir()/("."+appname);
}
#include <shlobj.h>
+#include <msp/core/application.h>
#include "dir.h"
using namespace std;
return ".";
}
-Path get_user_data_dir(const string &appname)
+Path get_user_data_dir(const string &)
{
+ return get_user_data_dir();
+}
+
+Path get_user_data_dir()
+{
+ const string &appname = Application::get_name();
if(appname.empty())
- throw invalid_argument("get_user_data_dir");
+ throw logic_error("no application name");
+
char datadir[MAX_PATH];
if(SHGetFolderPath(0, CSIDL_LOCAL_APPDATA, 0, 0, datadir)==S_OK)
return Path(datadir)/appname;
#include <msp/time/datetime.h>
+#include <msp/time/timedelta.h>
#include <msp/time/timestamp.h>
#include <msp/time/timezone.h>
-#include <msp/time/units.h>
#include <msp/test/test.h>
using namespace std;
#include <msp/core/thread.h>
#include <msp/io/pipe.h>
#include <msp/io/poll.h>
-#include <msp/time/units.h>
+#include <msp/time/timedelta.h>
#include <msp/test/test.h>
using namespace Msp;
#include <list>
#include <vector>
#include <msp/core/thread.h>
-#include <msp/time/units.h>
+#include <msp/time/timedelta.h>
#include <msp/time/utils.h>
#include <msp/test/test.h>
-#include <msp/time/units.h>
+#include <msp/time/timedelta.h>
#include <msp/time/timezone.h>
#include <msp/test/test.h>