]>
cygwin.com Git - cygwin-apps/setup.git/blob - IniParseFindVisitor.cc
2 * Copyright (c) 2002 Robert Collins.
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.
9 * A copy of the GNU General Public License can be found at
12 * Written by Robert Collins <robertc@hotmail.com>
17 static const char *cvsid
=
21 #include "IniParseFindVisitor.h"
22 #include "IniDBBuilder.h"
23 #include "io_stream.h"
28 extern int yyparse ();
30 IniParseFindVisitor::IniParseFindVisitor(IniDBBuilder
&aBuilder
, String
const &localroot
) : _Builder (aBuilder
), baseLength (localroot
.size()), local_ini(0),
31 error_buf(0), error_count (0),
32 setup_timestamp (0), setup_version() {}
33 IniParseFindVisitor::~IniParseFindVisitor(){}
35 /* look for potential packages we can add to the in-memory package
39 IniParseFindVisitor::visitFile(String
const &basePath
, const WIN32_FIND_DATA
*theFile
)
41 //TODO: Test for case sensitivity issues
42 if (String("setup.ini").casecompare(theFile
->cFileName
))
45 String path
= basePath
+ theFile
->cFileName
;
47 io_stream
*ini_file
= io_stream::open (String ("file://") + path
, "rb");
50 // We don't throw an exception, because while this is fatal to parsing, it
51 // isn't to the visitation.
53 // This should never happen
54 // If we want to handle it happening, use the log strategy call
55 throw new runtime_error ("IniParseFindVisitor: failed to open ini file, which should never happen");
59 // FIXME: use a strategy and tell about this as well.
60 // log (LOG_BABBLE, String ("Found ini file - file://") + local_dir + "/" + path);
62 /* Copy leading part of path to temporary buffer and unescape it */
64 String
prefix (&basePath
.cstr_oneuse()[baseLength
+ 1]);
65 String mirror
= rfc1738_unescape_part (prefix
.substr(0,prefix
.size() - 1));
66 _Builder
.parse_mirror
= mirror
;
67 ini_init (ini_file
, &_Builder
);
71 if (yyparse () || error_count
> 0)
72 // FIXME: use a stragtegy and tell on this.
73 //MessageBox (0, error_buf, error_count == 1 ? "Parse Error" : "Parse Errors", 0);
82 if (_Builder
.timestamp
> setup_timestamp
)
84 setup_timestamp
= _Builder
.timestamp
;
85 setup_version
= _Builder
.version
;
90 IniParseFindVisitor::iniCount() const
96 IniParseFindVisitor::timeStamp () const
98 return setup_timestamp
;
102 IniParseFindVisitor::version() const
104 return setup_version
;
This page took 0.038912 seconds and 5 git commands to generate.