wdir_watch.cpp: change header
wgfx: robustify gfx_get_video_mode wfilesystem: update comments wsnd: update comments to reflect use of readdir, not layer on top remove test_allocators (has been replaced by tests/ in lib/allocators) This was SVN commit r5449.
This commit is contained in:
parent
084ba8fcb0
commit
c057dd8f10
@ -17,7 +17,7 @@
|
||||
|
||||
#include "lib/path_util.h"
|
||||
#include "lib/allocators.h"
|
||||
#include "lib/res/file/file.h" // path_is_subpath
|
||||
#include "lib/path_util.h" // path_is_subpath
|
||||
#include "win.h"
|
||||
#include "winit.h"
|
||||
#include "wutil.h"
|
||||
|
@ -24,25 +24,28 @@
|
||||
// if we fail, outputs are unchanged (assumed initialized to defaults)
|
||||
LibError gfx_get_video_mode(int* xres, int* yres, int* bpp, int* freq)
|
||||
{
|
||||
// don't use EnumDisplaySettingsW - BoundsChecker reports it causes
|
||||
// a memory overrun (even if called as the very first thing, before
|
||||
// static CRT initialization).
|
||||
|
||||
DEVMODEA dm;
|
||||
memset(&dm, 0, sizeof(dm));
|
||||
dm.dmSize = sizeof(dm);
|
||||
// dm.dmDriverExtra already set to 0 by memset
|
||||
|
||||
// (Win2k: don't use EnumDisplaySettingsW - BoundsChecker reports it causes
|
||||
// a memory overrun, even if called as the very first thing before
|
||||
// static CRT initialization.)
|
||||
if(!EnumDisplaySettingsA(0, ENUM_CURRENT_SETTINGS, &dm))
|
||||
WARN_RETURN(ERR::FAIL);
|
||||
|
||||
if(dm.dmFields & (DWORD)DM_PELSWIDTH && xres)
|
||||
// EnumDisplaySettings is documented to set the values of the following:
|
||||
const DWORD expectedFlags = DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL|DM_DISPLAYFREQUENCY|DM_DISPLAYFLAGS;
|
||||
debug_assert((dm.dmFields & expectedFlags) == expectedFlags);
|
||||
|
||||
if(xres)
|
||||
*xres = (int)dm.dmPelsWidth;
|
||||
if(dm.dmFields & (DWORD)DM_PELSHEIGHT && yres)
|
||||
if(yres)
|
||||
*yres = (int)dm.dmPelsHeight;
|
||||
if(dm.dmFields & (DWORD)DM_BITSPERPEL && bpp)
|
||||
if(bpp)
|
||||
*bpp = (int)dm.dmBitsPerPel;
|
||||
if(dm.dmFields & (DWORD)DM_DISPLAYFREQUENCY && freq)
|
||||
if(freq)
|
||||
*freq = (int)dm.dmDisplayFrequency;
|
||||
|
||||
return INFO::OK;
|
||||
|
@ -337,7 +337,7 @@ fail:
|
||||
// return status for the dirent returned by the last successful
|
||||
// readdir call from the given directory stream.
|
||||
// currently sets st_size, st_mode, and st_mtime; the rest are zeroed.
|
||||
// non-portable, but considerably faster than stat(). used by file_enum.
|
||||
// non-portable, but considerably faster than stat(). used by dir_ForEachSortedEntry.
|
||||
int readdir_stat_np(DIR* d_, struct stat* s)
|
||||
{
|
||||
WDIR* d = (WDIR*)d_;
|
||||
|
@ -50,7 +50,7 @@ extern int closedir(DIR*);
|
||||
// return status for the file returned by the last successful
|
||||
// readdir call from the given directory stream.
|
||||
// currently sets st_size, st_mode, and st_mtime; the rest are zeroed.
|
||||
// non-portable, but considerably faster than stat(). used by file_enum.
|
||||
// non-portable, but considerably faster than stat(). used by dir_ForEachSortedEntry.
|
||||
extern int readdir_stat_np(DIR*, struct stat*);
|
||||
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <set>
|
||||
|
||||
#include "lib/path_util.h"
|
||||
#include "lib/res/file/file.h"
|
||||
#include "wposix/wfilesystem.h" // see add_oal_dlls_in_dir
|
||||
#include "wdll_ver.h"
|
||||
#include "win.h"
|
||||
@ -44,12 +43,10 @@ static LibError IsOpenAlDllName(const char* name)
|
||||
// directories on our search path).
|
||||
typedef std::set<std::string> StringSet;
|
||||
|
||||
// find all OpenAL DLLs in a dir (via file_enum and IsOpenAlDll).
|
||||
// find all OpenAL DLLs in a dir (via readdir and IsOpenAlDll).
|
||||
// call in library search order (exe dir, then win sys dir); otherwise,
|
||||
// DLLs in the executable's starting directory hide those of the
|
||||
// same name in the system directory.
|
||||
//
|
||||
// <dir>: no trailing.
|
||||
static LibError add_oal_dlls_in_dir(const char* path, StringSet* dlls)
|
||||
{
|
||||
// note: wdll_ver_list_add requires the full DLL path but readdir only
|
||||
|
@ -1,49 +0,0 @@
|
||||
#include "lib/self_test.h"
|
||||
|
||||
#include "lib/allocators.h"
|
||||
#include "lib/byte_order.h"
|
||||
#include "lib/res/file/file_io.h"
|
||||
|
||||
class TestAllocators : public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
void test_da()
|
||||
{
|
||||
DynArray da;
|
||||
|
||||
// basic test of functionality (not really meaningful)
|
||||
TS_ASSERT_OK(da_alloc(&da, 1000));
|
||||
TS_ASSERT_OK(da_set_size(&da, 1000));
|
||||
TS_ASSERT_OK(da_set_prot(&da, PROT_NONE));
|
||||
TS_ASSERT_OK(da_free(&da));
|
||||
|
||||
// test wrapping existing mem blocks for use with da_read
|
||||
u8 data[4] = { 0x12, 0x34, 0x56, 0x78 };
|
||||
TS_ASSERT_OK(da_wrap_fixed(&da, data, sizeof(data)));
|
||||
u8 buf[4];
|
||||
TS_ASSERT_OK(da_read(&da, buf, 4));
|
||||
TS_ASSERT_EQUALS(read_le32(buf), 0x78563412); // read correct value
|
||||
debug_skip_next_err(ERR::FAIL);
|
||||
TS_ASSERT(da_read(&da, buf, 1) < 0); // no more data left
|
||||
TS_ASSERT_OK(da_free(&da));
|
||||
}
|
||||
|
||||
void test_expand()
|
||||
{
|
||||
}
|
||||
|
||||
void test_matrix()
|
||||
{
|
||||
// not much we can do here; allocate a matrix, write to it and
|
||||
// make sure it can be freed.
|
||||
// (note: can't check memory layout because "matrix" is int** -
|
||||
// array of pointers. the matrix interface doesn't guarantee
|
||||
// that data comes in row-major order after the row pointers)
|
||||
int** m = (int**)matrix_alloc(3, 3, sizeof(int));
|
||||
m[0][0] = 1;
|
||||
m[0][1] = 2;
|
||||
m[1][0] = 3;
|
||||
m[2][2] = 4;
|
||||
matrix_free((void**)m);
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user