]> cygwin.com Git - cygwin-apps/setup.git/blob - SourceSetting.cc
2003-07-30 Robert Collins <rbtcollins@hotmail.com>
[cygwin-apps/setup.git] / SourceSetting.cc
1 /*
2 * Copyright (c) 2003, Robert Collins <rbtcollins@hotmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
11 *
12 * Written by Robert Collins.
13 *
14 */
15
16 #if 0
17 static const char *cvsid =
18 "\n%%% $Id$\n";
19 #endif
20
21 #include "SourceSetting.h"
22 #include "UserSettings.h"
23 #include "io_stream.h"
24 #include "state.h"
25 #include "resource.h"
26 #include "String++.h"
27
28 void
29 SourceSetting::load()
30 {
31 static int inited = 0;
32 if (inited)
33 return;
34 io_stream *f = UserSettings::Instance().settingFileForLoad("last-action");
35 if (f)
36 {
37 char localdir[1000];
38 char *fg_ret = f->gets (localdir, 1000);
39 delete f;
40 if (fg_ret)
41 source = sourceFromString(fg_ret);
42 }
43 inited = 1;
44 }
45
46 void
47 SourceSetting::save()
48 {
49
50 io_stream *f = UserSettings::Instance().settingFileForSave("last-action");
51 if (f)
52 {
53 switch (source) {
54 case IDC_SOURCE_DOWNLOAD:
55 f->write("Download\n",9);
56 break;
57 case IDC_SOURCE_NETINST:
58 f->write("Download,Install\n",17);
59 break;
60 case IDC_SOURCE_CWD:
61 f->write("Install\n",8);
62 break;
63 default:
64 break;
65 }
66 delete f;
67 }
68 }
69
70 int
71 SourceSetting::sourceFromString(String const & aSource)
72 {
73 if (!aSource.casecompare("Download"))
74 return IDC_SOURCE_DOWNLOAD;
75 if (!aSource.casecompare("Download,Install"))
76 return IDC_SOURCE_NETINST;
77 if (!aSource.casecompare("Install"))
78 return IDC_SOURCE_CWD;
79
80 /* A sanish default */
81 return IDC_SOURCE_NETINST;
82 }
This page took 0.03723 seconds and 5 git commands to generate.