Debian Codegraph @

src/files/castledownload_url_castlescript.inc

raw
1 {%MainUnit castledownload.pas}
2 {
3 Copyright 2013-2020 Michalis Kamburelis.
4
5 This file is part of "Castle Game Engine".
6
7 "Castle Game Engine" is free software; see the file COPYING.txt,
8 included in this distribution, for details about the copyright.
9
10 "Castle Game Engine" is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
14 ----------------------------------------------------------------------------
15 }
16
17 {$ifdef read_interface}
18
19 {$endif}
20
21 {$ifdef read_implementation}
22
23 { Handle castlescript protocols, to specify inline CastleScript code. }
24
25 { For historic reasons, special X3D scripting protocols
26 like ecmascript: or castle-script: are read by just stripping protocol,
27 not decoding with ParseURI. }
28 function InternalURIDeleteProtocol(const S: String): String;
29 begin
30 {$warnings off}
31 Result := URIDeleteProtocol(S);
32 {$warnings on}
33 end;
34
35 { TUrlCastleScript ------------------------------------------------------------------- }
36
37 type
38 TUrlCastleScript = class
39 class function Read(const Url: String; out MimeType: string): TStream;
40 class function MimeType(const URI: string; out Gzipped: Boolean): String;
41 end;
42
43 class function TUrlCastleScript.Read(const Url: String; out MimeType: string): TStream;
44 begin
45 MimeType := 'text/x-castlescript';
46 Result := MemoryStreamLoadFromString(InternalURIDeleteProtocol(URL));
47 end;
48
49 class function TUrlCastleScript.MimeType(const URI: string; out Gzipped: Boolean): String;
50 begin
51 Result := 'text/x-castlescript';
52 Gzipped := false;
53 end;
54
55 {$endif}