mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 22:49:23 +02:00
fcl-web: simpleserver: added option -m for mimetypes and default filename for darwin
git-svn-id: trunk@40366 -
This commit is contained in:
parent
deb3d5a0a9
commit
ee65da4429
@ -39,6 +39,7 @@
|
|||||||
</Target>
|
</Target>
|
||||||
<SearchPaths>
|
<SearchPaths>
|
||||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
|
<OtherUnitFiles Value="../../src/base"/>
|
||||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
|
@ -46,6 +46,7 @@ begin
|
|||||||
Writeln('-i --indexpage=name Directory index page to use (default: index.html)');
|
Writeln('-i --indexpage=name Directory index page to use (default: index.html)');
|
||||||
Writeln('-n --noindexpage Do not allow index page.');
|
Writeln('-n --noindexpage Do not allow index page.');
|
||||||
Writeln('-p --port=NNNN TCP/IP port to listen on (default is 3000)');
|
Writeln('-p --port=NNNN TCP/IP port to listen on (default is 3000)');
|
||||||
|
Writeln('-m --mimetypes=file path of mime.types, default under unix: /etc/mime.types');
|
||||||
Writeln('-q --quiet Do not write diagnostic messages');
|
Writeln('-q --quiet Do not write diagnostic messages');
|
||||||
Halt(Ord(Msg<>''));
|
Halt(Ord(Msg<>''));
|
||||||
end;
|
end;
|
||||||
@ -65,10 +66,24 @@ begin
|
|||||||
if D='' then
|
if D='' then
|
||||||
D:=GetCurrentDir;
|
D:=GetCurrentDir;
|
||||||
Log(etInfo,'Listening on port %d, serving files from directory: %s',[Port,D]);
|
Log(etInfo,'Listening on port %d, serving files from directory: %s',[Port,D]);
|
||||||
|
|
||||||
|
if HasOption('m','mimetypes') then
|
||||||
|
MimeTypesFile:=GetOptionValue('m','mimetypes');
|
||||||
{$ifdef unix}
|
{$ifdef unix}
|
||||||
MimeTypesFile:='/etc/mime.types';
|
if MimeTypesFile='' then
|
||||||
if not FileExists(MimeTypesFile) then
|
begin
|
||||||
MimeTypesFile:='';
|
MimeTypesFile:='/etc/mime.types';
|
||||||
|
if not FileExists(MimeTypesFile) then
|
||||||
|
begin
|
||||||
|
{$ifdef darwin}
|
||||||
|
MimeTypesFile:='/private/etc/apache2/mime.types';
|
||||||
|
if not FileExists(MimeTypesFile) then
|
||||||
|
{$endif}
|
||||||
|
MimeTypesFile:='';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if (MimeTypesFile<>'') and not FileExists(MimeTypesFile) then
|
||||||
|
Log(etWarning,'mimetypes file not found: '+MimeTypesFile);
|
||||||
{$endif}
|
{$endif}
|
||||||
TSimpleFileModule.BaseDir:=IncludeTrailingPathDelimiter(D);
|
TSimpleFileModule.BaseDir:=IncludeTrailingPathDelimiter(D);
|
||||||
TSimpleFileModule.OnLog:=@Log;
|
TSimpleFileModule.OnLog:=@Log;
|
||||||
|
Loading…
Reference in New Issue
Block a user