| 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 |
procedure CheckFileAccessSafe(const Url: String); |
| 24 |
begin |
| 25 |
if not ApplicationProperties._FileAccessSafe then |
| 26 |
WritelnWarning('Opening file "%s" before the Application.OnInitialize was called. ' + |
| 27 |
'This is not reliable on mobile platforms (Android, iOS). ' + |
| 28 |
'This usually happens if you open a file from the "initialization" section of a unit. ' + |
| 29 |
'You should do it in Application.OnInitialize instead.', |
| 30 |
[Url]); |
| 31 |
end; |
| 32 |
|
| 33 |
{ Extract MimeType from HTTP Content-Type. |
| 34 |
Returns empty string if Content-Type is empty (undefined). } |
| 35 |
function ContentTypeToMimeType(const ContentType: string): string; |
| 36 |
var |
| 37 |
P: Integer; |
| 38 |
begin |
| 39 |
P := Pos(';', ContentType); |
| 40 |
if P <> 0 then |
| 41 |
Result := Trim(Copy(ContentType, 1, P - 1)) |
| 42 |
else |
| 43 |
Result := Trim(ContentType); |
| 44 |
end; |
| 45 |
|
| 46 |
{$endif} |