1 //
2 // aegis - project change supervisor
3 // Copyright (C) 1996, 2002-2008, 2012 Peter Miller
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see
17 // <http://www.gnu.org/licenses/>.
18 //
19
20 #include <common/nstring/list.h>
21 #include <common/trace.h>
22 #include <common/wstring/list.h>
23 #include <libaegis/os.h>
24 #include <libaegis/sub.h>
25 #include <libaegis/sub/namemax.h>
26
27
28 wstring
sub_namemax(sub_context_ty * scp,const wstring_list & arg)29 sub_namemax(sub_context_ty *scp, const wstring_list &arg)
30 {
31 trace(("sub_namemax()\n{\n"));
32 wstring result;
33 if (arg.size() < 2)
34 {
35 scp->error_set(i18n("requires one argument"));
36 trace(("}\n"));
37 return result;
38 }
39
40 nstring_list results;
41 os_become_orig();
42 for (size_t j = 1; j < arg.size(); ++j)
43 {
44 nstring s = arg[j].to_nstring();
45 trace(("s = %s;\n", s.quote_c().c_str()));
46 int n = os_pathconf_name_max(s);
47 s = nstring::format("%d", n);
48 trace(("result = %s;\n", s.quote_c().c_str()));
49 results.push_back(s);
50 }
51 os_become_undo();
52
53 nstring s = results.unsplit();
54 result = wstring(s);
55 trace(("return %p;\n", result.get_ref()));
56 trace(("}\n"));
57 return result;
58 }
59
60
61 // vim: set ts=8 sw=4 et :
62