]> cygwin.com Git - cygwin-apps/setup.git/blame - fromcwd.cc
* Makefile.am: Treat libgetopt++ as full-fledged SUBDIRS.
[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"
5072c0bb 46#include "ini.h"
23c9e63c 47
b401ef47 48#include "IniDBBuilderPackage.h"
67829ce0 49#include "IniParseFeedback.h"
21f325d7 50
b401ef47 51/* Trivial class for detecting the existence of setup.ini */
21f325d7 52
b401ef47
RC
53class SetupFindVisitor : public FindVisitor
54{
55public:
56 SetupFindVisitor (): found(false){}
fd93eff9
MB
57 virtual void visitFile(const std::string& basePath,
58 const WIN32_FIND_DATA *theFile)
5f48f258 59 {
5072c0bb 60 if (!casecompare(SETUP_INI_FILENAME, theFile->cFileName) &&
b401ef47
RC
61 (theFile->nFileSizeLow || theFile->nFileSizeHigh))
62 found = true;
5f48f258 63 }
b401ef47
RC
64 virtual ~ SetupFindVisitor (){}
65 operator bool () const {return found;}
66protected:
67 SetupFindVisitor (SetupFindVisitor const &);
68 SetupFindVisitor & operator= (SetupFindVisitor const &);
69private:
70 bool found;
71};
72
55c6e691 73bool
ab57ceaa 74do_fromcwd (HINSTANCE h, HWND owner)
23c9e63c 75{
ab57ceaa 76 // Assume we won't find the INI file.
b401ef47
RC
77 SetupFindVisitor found_ini;
78 Find(".").accept(found_ini);
de6a1a64 79 if (found_ini)
858f100d
RC
80 {
81 // Found INI, load it.
55c6e691 82 return true;
858f100d 83 }
23c9e63c 84
67829ce0
RC
85 IniParseFeedback myFeedback;
86 IniDBBuilderPackage myBuilder(myFeedback);
b401ef47
RC
87 ScanFindVisitor myVisitor (myBuilder);
88 Find(".").accept(myVisitor);
55c6e691 89 return false;
23c9e63c 90}
This page took 0.059378 seconds and 5 git commands to generate.