Re: URL to filename conversion
- From: Gregory Hosler <ghosler redhat com>
- To: Kevin DeKorte <kdekorte gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: URL to filename conversion
- Date: Mon, 12 May 2008 22:28:42 +0800
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Kevin DeKorte wrote:
| Is there is a GLIB function that takes a name like
|
| file:///home/user/name%20with%20spaces.txt
|
| and turns it into
|
| /home/user/name with spaces.txt
|
| Or even something that is close?
|
| Thanks,
|
| Kevin
I had the same problem, for handling uri's and I wrote the following code. Feel free to
borrow/use...
Warning, it does in place massaging of the input string. It's just as easy to strdup() the
string, and massage the returned string, if re-entrancy is important (the place where this
was used, re-entrancy was a non-issue...)
Oh, and the processing of the %20's is an ugly hack...
- -Greg
======================
gchar *getpathfromuri(gchar *uri)
{
gchar *new;
char *ptr;
if (uri) {
ptr = strstr(uri, "%20");
while (ptr) {
*ptr = ' ';
strcpy(ptr+1, ptr+3);
ptr = strstr(ptr+1, "%20");
}
// find the last of the first slashes (file:///home...)
new = strstr(uri, "/");
while(*new == '/') new++;
return (gchar *)(--new);
}
return NULL;
}
|
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
- --
+---------------------------------------------------------------------+
Please also check the log file at "/dev/null" for additional information.
(from /var/log/Xorg.setup.log)
| Greg Hosler ghosler redhat com |
+---------------------------------------------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
iD8DBQFIKFQY404fl/0CV/QRAvCQAJ9uFv9VTfpWxC6hLHkdFkl7SMRcFQCgsmjL
0lkkGaq3BaBLfNIjPoVaJqQ=
=V/pc
-----END PGP SIGNATURE-----
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]