Skip to content

Commit 4410471

Browse files
author
Jin Jae-yeon
committed
Add INI, CONFIG Detectors
1 parent 3eeeb0a commit 4410471

8 files changed

+2038
-1
lines changed

Daramee.FileTypeDetector/AbstractRegexSignatureDetector.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public abstract class AbstractRegexSignatureDetector : IDetector
1717

1818
public virtual bool Detect ( Stream stream )
1919
{
20-
int readBufferSize = Signature.ToString ().Length * 64;
20+
int readBufferSize = Signature.ToString ().Length * 8;
2121
char [] buffer = new char [ readBufferSize ];
2222

2323
var encodings = new []

Daramee.FileTypeDetector/Daramee.FileTypeDetector.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
<Compile Include="AbstractISOBaseMediaFileDetailDetector.cs" />
3838
<Compile Include="DetectorService.cs" />
3939
<Compile Include="Detectors\Bzip2Detector.cs" />
40+
<Compile Include="Detectors\ConfigurationDetector.cs" />
4041
<Compile Include="Detectors\DirectDrawSurfaceFormatDetector.cs" />
42+
<Compile Include="Detectors\InitializationDetector.cs" />
4143
<Compile Include="Detectors\M4ADetector.cs" />
4244
<Compile Include="Detectors\ApkDetector.cs" />
4345
<Compile Include="Detectors\AudioVideoInterleaveDetector.cs" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Xml;
8+
9+
namespace Daramee.FileTypeDetector.Detectors
10+
{
11+
class ConfigurationDetector : IDetector
12+
{
13+
public string Precondition => "txt";
14+
public string Extension => "config";
15+
16+
public bool Detect ( Stream stream )
17+
{
18+
try
19+
{
20+
System.Xml.XmlReader reader = XmlReader.Create ( stream, new XmlReaderSettings () { } );
21+
if ( reader.Read () )
22+
{
23+
if ( reader.IsStartElement () )
24+
{
25+
if ( reader.Name == "configuration" )
26+
{
27+
return true;
28+
}
29+
}
30+
}
31+
}
32+
catch { }
33+
34+
return false;
35+
}
36+
37+
public override string ToString () => "Microsoft .NET Configuration File Detector";
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Text.RegularExpressions;
6+
using System.Threading.Tasks;
7+
8+
namespace Daramee.FileTypeDetector.Detectors
9+
{
10+
class InitializationDetector : AbstractRegexSignatureDetector
11+
{
12+
public override string Precondition => "txt";
13+
public override string Extension => "ini";
14+
15+
protected override Regex Signature => new Regex ( "^(\\[(.*)\\]\r?\n((((.*)=(.*))*|(;(.*)))\r?\n)*)+" );
16+
17+
public override string ToString () => "Initialization File Detector";
18+
}
19+
}

FTD.Test/Examples/CONFIG Test 1

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<configuration>
2+
<dllmap os="linux" dll="opengl32.dll" target="libGL.so.1"/>
3+
<dllmap os="linux" dll="glu32.dll" target="libGLU.so.1"/>
4+
<dllmap os="linux" dll="openal32.dll" target="libopenal.so.1"/>
5+
<dllmap os="linux" dll="alut.dll" target="libalut.so.0"/>
6+
<dllmap os="linux" dll="opencl.dll" target="libOpenCL.so"/>
7+
<dllmap os="linux" dll="libX11" target="libX11.so.6"/>
8+
<dllmap os="linux" dll="libXi" target="libXi.so.6"/>
9+
<dllmap os="linux" dll="SDL2.dll" target="libSDL2-2.0.so.0"/>
10+
<dllmap os="osx" dll="opengl32.dll" target="/System/Library/Frameworks/OpenGL.framework/OpenGL"/>
11+
<dllmap os="osx" dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
12+
<dllmap os="osx" dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
13+
<dllmap os="osx" dll="libGLES.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
14+
<dllmap os="osx" dll="libGLESv1_CM.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
15+
<dllmap os="osx" dll="libGLESv2.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
16+
<dllmap os="osx" dll="opencl.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/>
17+
<dllmap os="osx" dll="SDL2.dll" target="libSDL2.dylib"/>
18+
<!-- XQuartz compatibility (X11 on Mac) -->
19+
<dllmap os="osx" dll="libGL.so.1" target="/usr/X11/lib/libGL.dylib"/>
20+
<dllmap os="osx" dll="libX11" target="/usr/X11/lib/libX11.dylib"/>
21+
<dllmap os="osx" dll="libXcursor.so.1" target="/usr/X11/lib/libXcursor.dylib"/>
22+
<dllmap os="osx" dll="libXi" target="/usr/X11/lib/libXi.dylib"/>
23+
<dllmap os="osx" dll="libXinerama" target="/usr/X11/lib/libXinerama.dylib"/>
24+
<dllmap os="osx" dll="libXrandr.so.2" target="/usr/X11/lib/libXrandr.dylib"/>
25+
</configuration>

0 commit comments

Comments
 (0)