[Mono-list] Mono.Unix.Magic libmagic wrapper

Milosz Tanski milosz at mindtouchsoftware.com
Sat Sep 23 10:59:00 EDT 2006


Jonathan,

As far windows is concerned, there exists a native port of file and the
associated library at http://gnuwin32.sourceforge.net/packages/file.htm
. However, it doesn't seam that too many people or projects use it. I
don't have steady access to a win32 dev box to give it a whirl. So I'm
sure what do with the name space now... although Mono.Unix have the warm
fuzzy feeling of correctness/content.

The class name of Magic can be defiantly confusing/entertaining for the
user who stumbles upon it for the first time. The other thing name that
comes to my mind is FileMagicDatabase.

I'm willing to write the documentation as soon as this is done, and I
figure out how to do it...

I've updated the bindings with the things you recommended, and I
integrated it with the build system. I haven't tackled your point #4
since I wasn't sure how to approach it exactly.

Jonathan Pryor wrote:
> On Fri, 2006-09-22 at 23:25 -0400, Milosz Tanski wrote:
>> I wrote a wrapper for the unix libmagic library since it's very handy
>> sometimes (and I'm using this wrapper in my app right now, so I figured
>> might as well submit it). Sorry that's it's not a diff, but I'd know
>> exactly how to integrate it with the class library build system.
> 
> I have a few questions/concerns/observations:
> 
> 1.  Can libmagic be used on Windows without the use of Cygwin?  I think
> it can be, but I'm not entirely sure.  If it can be, I'm not sure that
> Mono.Unix is the best place for it (deliberately ignoring the Mono.Unix
> types which can work on Windows, Mono.Unix.Native.Stdlib &
> Mono.Unix.Native.StdioFileStream).  If libmagic can't work on Windows
> without Cygwin, then Mono.Unix is probably a reasonable spot for it.
> 
> 2.  I'm not fond of the name "Magic."  Yes, it's a `libmagic' wrapper,
> but for those who don't know what `libmagic' is, it's not a very
> informative name.  Considering that it's used by the file(1) command,
> I'm sure some better name could be found.  Perhaps FileTypeInfo?
> 
> Of course, any name would need to be "stand-alone"-ish, and not be
> easily confused with the existing UnixFileSystemInfo & UnixFileInfo
> types.
> 3.  The Magic.Descrition property should be Magic.Description.
> 
> 4.  You should get libmagic to generate UTF-8 (it it doesn't do so by
> default) and use UnixEncoding to do the UTF-8 -> string conversion (in
> case Mono's Marshal.PtrToStringAuto ever stops doing UTF-8, and there's
> a bug open to investigate that).
> 
> 5.  If it does get into Mono.Unix, the magic_* methods taking a filename
> should make use of the Mono.Unix.Native.FileNameMarshaler custom
> marshaler for "proper" filename transfers (for when a filename contains
> random binary data instead of being valid UTF-8).  See
> Mono.Unix.Native.Syscall.
> 
> 6.  Documentation -- are you willing to write it? :-)
>
> 
> Thank you for the file.
> 
>  - Jon
> 
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: FileMagicDb.patch
Type: text/x-patch
Size: 7653 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-list/attachments/20060923/69278949/attachment-0001.bin 


More information about the Mono-list mailing list