From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,225336ae711b78f1 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder3.cambriumusenet.nl!feed.tweaknews.nl!193.141.40.65.MISMATCH!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Open URLs Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Sun, 3 Jan 2010 21:05:46 +0100 Message-ID: <1exooomj74fsx.1k5y7r1avujek$.dlg@40tude.net> NNTP-Posting-Date: 03 Jan 2010 21:05:47 CET NNTP-Posting-Host: bfcd23c7.newsspool2.arcor-online.net X-Trace: DXC=oGP7LBOhe9aOKO]LCQ@0g`A9EHlD;3Ycb4Fo<]lROoRa8kF On Sun, 3 Jan 2010 10:17:58 -0800 (PST), vlc wrote: > I am looking for a way to open URLs (like "file:///home/vlc/file") as > files - as you would do with "Open (Handle, In_File, "/home/vlc/ > file")". > > I could surely just remove the heading "file://", but this would still > leave me with the problem of special characters like "file:///home/vlc/ > name%20with%20spaces". The third / is a delimiter, theoretically there could be something between file:// and /. The path might be followed by queries and fragments, see here: http://en.wikipedia.org/wiki/URI_scheme#Generic_syntax > Does anybody know of a way to translate URLs to paths? You just parse it. What is the problem, except that the number of URI schemes is huge. Regarding replacing %20 with SP, I am not sure if this has to be done. You have to dig the documents (RFC) to verify if % is indeed a defined escape sequence, if there are any in the URI, I do not remember. Otherwise it is a part of the file name to be passed further as is. In any case, when you write a parser, you could make it recognize escape sequences, delimiters etc as it moves the cursor left to right. Something like: Pointer := URI'First; ... -- Get scheme, advance pointer case Scheme is when File_Schema => declare Path : Unbounded_String; Code_Point : Integer; begin loop if URI (Pointer) = '%' then Get (URI, Pointer, Code_Point); Append (Path, Character'Val (Code_Point)); elsif Is_In (Delimiters, URI (Pointer)) then exit; else Append (Path, URI (Pointer)); Pointer := Pointer + 1; end if; exit when Pointer > URI'Last; end loop; ... etc -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de