]>
git.saurik.com Git - apt-legacy.git/blob - methods/file.cc
2 #include <mach-o/nlist.h>
5 // -*- mode: cpp; mode: fold -*-
7 // $Id: file.cc,v 1.9.2.1 2004/01/16 18:58:50 mdz Exp $
8 /* ######################################################################
10 File URI method for APT
12 This simply checks that the file specified exists, if so the relevent
13 information is returned. If a .gz filename is specified then the file
14 name with .gz removed will also be checked and information about it
15 will be returned in Alt-*
17 ##################################################################### */
19 // Include Files /*{{{*/
20 #include <apt-pkg/acquire-method.h>
21 #include <apt-pkg/error.h>
22 #include <apt-pkg/hashes.h>
23 #include <apt-pkg/fileutl.h>
30 class FileMethod
: public pkgAcqMethod
32 virtual bool Fetch(FetchItem
*Itm
);
36 FileMethod() : pkgAcqMethod("1.0",SingleInstance
| LocalOnly
) {};
39 // FileMethod::Fetch - Fetch a file /*{{{*/
40 // ---------------------------------------------------------------------
42 bool FileMethod::Fetch(FetchItem
*Itm
)
45 string File
= Get
.Path
;
47 if (Get
.Host
.empty() == false)
48 return _error
->Error(_("Invalid URI, local URIS must not start with //"));
50 // See if the file exists
52 if (stat(File
.c_str(),&Buf
) == 0)
54 Res
.Size
= Buf
.st_size
;
56 Res
.LastModified
= Buf
.st_mtime
;
58 if (Itm
->LastModified
== Buf
.st_mtime
&& Itm
->LastModified
!= 0)
62 // See if we can compute a file without a .gz exentsion
63 string::size_type Pos
= File
.rfind(".gz");
64 if (Pos
+ 3 == File
.length())
66 File
= string(File
,0,Pos
);
67 if (stat(File
.c_str(),&Buf
) == 0)
70 AltRes
.Size
= Buf
.st_size
;
71 AltRes
.Filename
= File
;
72 AltRes
.LastModified
= Buf
.st_mtime
;
73 AltRes
.IMSHit
= false;
74 if (Itm
->LastModified
== Buf
.st_mtime
&& Itm
->LastModified
!= 0)
82 if (Res
.Filename
.empty() == true)
83 return _error
->Error(_("File not found"));
86 FileFd
Fd(Res
.Filename
, FileFd::ReadOnly
);
87 Hash
.AddFD(Fd
.Fd(), Fd
.Size());
96 #if !defined(__ENVIRONMENT_ASPEN_VERSION_MIN_REQUIRED__) || __ENVIRONMENT_ASPEN_VERSION_MIN_REQUIRED__ < 10200
98 memset(nl
, 0, sizeof(nl
));
99 nl
[0].n_un
.n_name
= (char *) "_useMDNSResponder";
100 nlist("/usr/lib/libc.dylib", nl
);
101 if (nl
[0].n_type
!= N_UNDF
)
102 *(int *) nl
[0].n_value
= 0;
105 setlocale(LC_ALL
, "");