]> cygwin.com Git - cygwin-apps/setup.git/blame - fromcwd.cc
2002-07-05 Robert Collins <rbtcollins@hotmail.com>
[cygwin-apps/setup.git] / fromcwd.cc
CommitLineData
23c9e63c
DD
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
ca83c665 28#if 0
b24c88b3
RC
29static const char *cvsid =
30 "\n%%% $Id$\n";
ca83c665 31#endif
8507f105 32
23c9e63c
DD
33#include "win32.h"
34
35#include <stdio.h>
36#include <stdlib.h>
23c9e63c 37#include <unistd.h>
23c9e63c 38
23c9e63c 39#include "resource.h"
23c9e63c
DD
40#include "state.h"
41#include "dialog.h"
42#include "msg.h"
43#include "find.h"
b401ef47 44#include "ScanFindVisitor.h"
fb087b80 45#include "filemanip.h"
13d27274 46#include "version.h"
23c9e63c
DD
47
48#include "port.h"
49
b401ef47 50#include "IniDBBuilderPackage.h"
67829ce0 51#include "IniParseFeedback.h"
21f325d7 52
b401ef47 53/* Trivial class for detecting the existence of setup.ini */
21f325d7 54
b401ef47
RC
55class SetupFindVisitor : public FindVisitor
56{
57public:
58 SetupFindVisitor (): found(false){}
59 virtual void visitFile(String const &basePath, const WIN32_FIND_DATA *theFile)
5f48f258 60 {
b401ef47
RC
61 if (!String ("setup.ini").casecompare(theFile->cFileName) &&
62 (theFile->nFileSizeLow || theFile->nFileSizeHigh))
63 found = true;
5f48f258 64 }
b401ef47
RC
65 virtual ~ SetupFindVisitor (){}
66 operator bool () const {return found;}
67protected:
68 SetupFindVisitor (SetupFindVisitor const &);
69 SetupFindVisitor & operator= (SetupFindVisitor const &);
70private:
71 bool found;
72};
73
23c9e63c 74void
ab57ceaa 75do_fromcwd (HINSTANCE h, HWND owner)
23c9e63c 76{
ab57ceaa 77 // Assume we won't find the INI file.
b401ef47
RC
78 SetupFindVisitor found_ini;
79 Find(".").accept(found_ini);
de6a1a64 80 if (found_ini)
858f100d
RC
81 {
82 // Found INI, load it.
83 next_dialog = IDD_S_LOAD_INI;
23c9e63c 84 return;
858f100d 85 }
23c9e63c 86
f6a81f69 87 next_dialog = IDD_CHOOSE;
23c9e63c 88
67829ce0
RC
89 IniParseFeedback myFeedback;
90 IniDBBuilderPackage myBuilder(myFeedback);
b401ef47
RC
91 ScanFindVisitor myVisitor (myBuilder);
92 Find(".").accept(myVisitor);
23c9e63c
DD
93 return;
94}
This page took 0.044243 seconds and 5 git commands to generate.