From eb6e23e1de0c05f10288a1493b5c98fda9f87d8f Mon Sep 17 00:00:00 2001 From: Thomas Mullaly Date: Sun, 25 Jul 2010 18:19:48 -0400 Subject: [PATCH] urlmon: Implemented function to the file extension of a file in a URI path. --- dlls/urlmon/uri.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/dlls/urlmon/uri.c b/dlls/urlmon/uri.c index 07e99449d61..20a2d87a175 100644 --- a/dlls/urlmon/uri.c +++ b/dlls/urlmon/uri.c @@ -61,6 +61,7 @@ typedef struct { INT path_start; DWORD path_len; + INT extension_offset; } Uri; typedef struct { @@ -535,6 +536,18 @@ static DWORD remove_dot_segments(WCHAR *path, DWORD path_len) { return len; } +/* Attempts to find the file extension in a given path. */ +static INT find_file_extension(const WCHAR *path, DWORD path_len) { + const WCHAR *end; + + for(end = path+path_len-1; end >= path && *end != '/' && *end != '\\'; --end) { + if(*end == '.') + return end-path; + } + + return -1; +} + /* Computes the location where the elision should occur in the IPv6 * address using the numerical values of each component stored in * 'values'. If the address shouldn't contain an elision then 'index' @@ -2576,6 +2589,12 @@ static BOOL canonicalize_hierpart(const parse_data *data, Uri *uri, DWORD flags, return FALSE; } + if(uri->path_start > -1 && !computeOnly) + /* Finding file extensions happens for both types of URIs. */ + uri->extension_offset = find_file_extension(uri->canon_uri+uri->path_start, uri->path_len); + else + uri->extension_offset = -1; + return TRUE; }