diff options
author | Arch Librarian <arch@canonical.com> | 2004-09-20 16:50:51 +0000 |
---|---|---|
committer | Arch Librarian <arch@canonical.com> | 2004-09-20 16:50:51 +0000 |
commit | ad00ae81eb9e1f5384f8fe32879d483c72bbdace (patch) | |
tree | 90dc3818bc981902022cf43d1f44dc0c1fd2a45c /apt-pkg/contrib/strutl.cc | |
parent | 8efa2a3ba4ae833415223a888e4561e57e4bf132 (diff) |
DumpAvail works and apt-cache is complete
Author: jgg
Date: 1998-07-19 04:22:00 GMT
DumpAvail works and apt-cache is complete
Diffstat (limited to 'apt-pkg/contrib/strutl.cc')
-rw-r--r-- | apt-pkg/contrib/strutl.cc | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 8c1f7005c..f30d9ffe7 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: strutl.cc,v 1.2 1998/07/16 06:08:41 jgg Exp $ +// $Id: strutl.cc,v 1.3 1998/07/19 04:22:08 jgg Exp $ /* ###################################################################### String Util - Some usefull string functions. @@ -243,6 +243,25 @@ string SubstVar(string Str,string Subst,string Contents) return Temp + string(Str,OldPos); } /*}}}*/ +// URItoFileName - Convert the uri into a unique file name /*{{{*/ +// --------------------------------------------------------------------- +/* This converts a URI into a safe filename. It quotes all unsafe characters + and converts / to _ and removes the scheme identifier. The resulting + file name should be unique and never occur again for a different file */ +string URItoFileName(string URI) +{ + string::const_iterator I = URI.begin() + URI.find(':') + 1; + for (; I < URI.end() && *I == '/'; I++); + + // "\x00-\x20{}|\\\\^\\[\\]<>\"\x7F-\xFF"; + URI = QuoteString(string(I,URI.end() - I),"\\|{}[]<>\"^~_=!@#$%^&*"); + string::iterator J = URI.begin(); + for (; J != URI.end(); J++) + if (*J == '/') + *J = '_'; + return URI; +} + /*}}}*/ // Base64Encode - Base64 Encoding routine for short strings /*{{{*/ // --------------------------------------------------------------------- /* This routine performs a base64 transformation on a string. It was ripped |