diff --git a/SharpPhysFS/PhysFS.cs b/SharpPhysFS/PhysFS.cs index dee5389..0cb760c 100644 --- a/SharpPhysFS/PhysFS.cs +++ b/SharpPhysFS/PhysFS.cs @@ -178,10 +178,7 @@ namespace SharpPhysFS public string[] EnumerateFiles(string dir) { var list = new List(); - EnumerateFilesCallback(dir, (d, o, f) => - { - list.Add(f); - }, null); + EnumerateFilesCallback(dir, (o, f) => list.Add(f)); return list.ToArray(); } @@ -258,10 +255,7 @@ namespace SharpPhysFS public string[] GetCdRomDirs() { var list = new List(); - GetCdRomDirsCallback((d, s) => - { - list.Add(s); - }, null); + GetCdRomDirsCallback((s) => list.Add(s)); return list.ToArray(); } @@ -359,13 +353,8 @@ namespace SharpPhysFS /// public string[] GetSearchPath() { - //var dirs = Interop.PHYSFS_getSearchPath(); - //return GenEnumerable(dirs); var list = new List(); - GetSearchPathCallback((d, s) => - { - list.Add(s); - }, null); + GetSearchPathCallback((s) => list.Add(s)); return list.ToArray(); } @@ -616,6 +605,7 @@ namespace SharpPhysFS }; } + [Obsolete("The non-generic variant of GetCdRomDirsCallback is meant for internal use only. Consider using one of the generic alternatives.")] public void GetCdRomDirsCallback(StringCallback c, object data) { GCHandle objHandle = GCHandle.Alloc(data); @@ -626,6 +616,10 @@ namespace SharpPhysFS /// /// Enumerate CD-ROM directories, using an application-defined callback. /// + /// + /// if you don't need to pass + /// custom data to the callback. + /// /// Type of data passed to callback /// Callback function to notify about detected drives. /// Application-defined data passed to callback. Can be null. @@ -634,6 +628,16 @@ namespace SharpPhysFS GetCdRomDirsCallback(WrapStringCallback(c), data); } + /// + /// Enumerate CD-ROM directories, using an application-defined callback. + /// + /// Callback function to notify about detected drives. + public void GetCdRomDirsCallback(Action c) + { + interop.PHYSFS_getCdRomDirsCallback((p, s) => c(s), IntPtr.Zero); + } + + [Obsolete("The non-generic variant of GetSearchPathCallback is meant for internal use only. Consider using one of the generic alternatives.")] public void GetSearchPathCallback(StringCallback c, object data) { GCHandle objHandle = GCHandle.Alloc(data); @@ -644,6 +648,10 @@ namespace SharpPhysFS /// /// Enumerate the search path, using an application-defined callback. /// + /// + /// if you don't need to pass + /// custom data to the callback. + /// /// Type of data passed to callback /// Callback function to notify about search path elements. /// Application-defined data passed to callback. Can be null. @@ -652,6 +660,16 @@ namespace SharpPhysFS GetSearchPathCallback(WrapStringCallback(c), data); } + /// + /// Enumerate the search path, using an application-defined callback. + /// + /// Callback function to notify about search path elements. + public void GetSearchPathCallback(Action c) + { + interop.PHYSFS_getSearchPathCallback((p, s) => c(s), IntPtr.Zero); + } + + [Obsolete("The non-generic variant of EnumerateFilesCallback is meant for internal use only. Consider using one of the generic alternatives.")] public void EnumerateFilesCallback(string dir, EnumFilesCallback c, object data) { GCHandle objHandle = GCHandle.Alloc(data); @@ -662,6 +680,10 @@ namespace SharpPhysFS /// /// Get a file listing of a search path's directory, using an application-defined callback. /// + /// + /// if you don't need + /// to pass custom data to the callback. + /// /// Type of data passed to callbakc /// Directory, in platform-independent notation, to enumerate. /// Callback function to notify about search path elements. @@ -675,6 +697,16 @@ namespace SharpPhysFS }, data); } + /// + /// Get a file listing of a search path's directory, using an application-defined callback. + /// + /// Directory, in platform-independent notation, to enumerate. + /// Callback function to notify about search path elements. + public void EnumerateFilesCallback(string dir, Action c) + { + interop.PHYSFS_enumerateFilesCallback(dir, (data, origdir, fname) => c(origdir, fname), IntPtr.Zero); + } + public PhysFSStream OpenAppend(string file) { var handle = LowLevel.OpenAppend(file, this);