]> cygwin.com Git - cygwin-apps/setup.git/blob - fromcwd.cc
2004-12-26 Max Bowsher <maxb@ukf.net>
[cygwin-apps/setup.git] / fromcwd.cc
1 /*
2 * Copyright (c) 2000, Red Hat, Inc.
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 DJ Delorie <dj@cygnus.com>
13 *
14 */
15
16 /* The purpose of this file is to handle the case where we're
17 installing from files that already exist in the current directory.
18 If a setup.ini file is present, we set the mirror site to "." and
19 pretend we're installing from the `internet' ;-) else we have to
20 find all the .tar.gz files, deduce their versions, and try to
21 compare versions in the case where the current directory contains
22 multiple versions of any given package. We do *not* try to compare
23 versions with already installed packages; we always choose a
24 package in the current directory over one that's already installed
25 (otherwise, why would you have asked to install it?). Note
26 that we search recursively. */
27
28 #if 0
29 static const char *cvsid =
30 "\n%%% $Id$\n";
31 #endif
32
33 #include "win32.h"
34
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <unistd.h>
38
39 #include "resource.h"
40 #include "state.h"
41 #include "dialog.h"
42 #include "msg.h"
43 #include "find.h"
44 #include "ScanFindVisitor.h"
45 #include "filemanip.h"
46
47 #include "IniDBBuilderPackage.h"
48 #include "IniParseFeedback.h"
49
50 /* Trivial class for detecting the existence of setup.ini */
51
52 class SetupFindVisitor : public FindVisitor
53 {
54 public:
55 SetupFindVisitor (): found(false){}
56 virtual void visitFile(String const &basePath, const WIN32_FIND_DATA *theFile)
57 {
58 if (!String ("setup.ini").casecompare(theFile->cFileName) &&
59 (theFile->nFileSizeLow || theFile->nFileSizeHigh))
60 found = true;
61 }
62 virtual ~ SetupFindVisitor (){}
63 operator bool () const {return found;}
64 protected:
65 SetupFindVisitor (SetupFindVisitor const &);
66 SetupFindVisitor & operator= (SetupFindVisitor const &);
67 private:
68 bool found;
69 };
70
71 bool
72 do_fromcwd (HINSTANCE h, HWND owner)
73 {
74 // Assume we won't find the INI file.
75 SetupFindVisitor found_ini;
76 Find(".").accept(found_ini);
77 if (found_ini)
78 {
79 // Found INI, load it.
80 return true;
81 }
82
83 IniParseFeedback myFeedback;
84 IniDBBuilderPackage myBuilder(myFeedback);
85 ScanFindVisitor myVisitor (myBuilder);
86 Find(".").accept(myVisitor);
87 return false;
88 }
This page took 0.037191 seconds and 5 git commands to generate.