]>
git.saurik.com Git - apt-legacy.git/blob - methods/copy.cc
2 #include <mach-o/nlist.h>
5 // -*- mode: cpp; mode: fold -*-
7 // $Id: copy.cc,v 1.7.2.1 2004/01/16 18:58:50 mdz Exp $
8 /* ######################################################################
10 Copy URI - This method takes a uri like a file: uri and copies it
11 to the destination file.
13 ##################################################################### */
15 // Include Files /*{{{*/
16 #include <apt-pkg/fileutl.h>
17 #include <apt-pkg/acquire-method.h>
18 #include <apt-pkg/error.h>
26 class CopyMethod
: public pkgAcqMethod
28 virtual bool Fetch(FetchItem
*Itm
);
32 CopyMethod() : pkgAcqMethod("1.0",SingleInstance
) {};
35 // CopyMethod::Fetch - Fetch a file /*{{{*/
36 // ---------------------------------------------------------------------
38 bool CopyMethod::Fetch(FetchItem
*Itm
)
41 string File
= Get
.Path
;
43 // Stat the file and send a start message
45 if (stat(File
.c_str(),&Buf
) != 0)
46 return _error
->Errno("stat",_("Failed to stat"));
48 // Forumulate a result and send a start message
50 Res
.Size
= Buf
.st_size
;
51 Res
.Filename
= Itm
->DestFile
;
52 Res
.LastModified
= Buf
.st_mtime
;
56 // See if the file exists
57 FileFd
From(File
,FileFd::ReadOnly
);
58 FileFd
To(Itm
->DestFile
,FileFd::WriteEmpty
);
60 if (_error
->PendingError() == true)
67 if (CopyFile(From
,To
) == false)
76 // Transfer the modification times
77 struct utimbuf TimeBuf
;
78 TimeBuf
.actime
= Buf
.st_atime
;
79 TimeBuf
.modtime
= Buf
.st_mtime
;
80 if (utime(Itm
->DestFile
.c_str(),&TimeBuf
) != 0)
83 return _error
->Errno("utime",_("Failed to set modification time"));
93 #if !defined(__ENVIRONMENT_ASPEN_VERSION_MIN_REQUIRED__) || __ENVIRONMENT_ASPEN_VERSION_MIN_REQUIRED__ < 10200
95 memset(nl
, 0, sizeof(nl
));
96 nl
[0].n_un
.n_name
= (char *) "_useMDNSResponder";
97 nlist("/usr/lib/libc.dylib", nl
);
98 if (nl
[0].n_type
!= N_UNDF
)
99 *(int *) nl
[0].n_value
= 0;
102 setlocale(LC_ALL
, "");