示例#1
0
ForceInline Int main2(Int argc, WChar **argv)
{
    if (argc == 1)
    {
        printf("ToB (Text of Binary) Compiler 0.3 [by dwing] 2009-02-28\n"
               "Usage: tobc <src_file> [dst_file]\n");
        return 1;
    }

    BOOL   Result;
    WCHAR  szCurPath[MAX_PATH], szScriptPath[MAX_PATH];
    LPWSTR fsrcname, fdstname;

    fsrcname = argv[1];
    fdstname = argc > 2 ? argv[2] : NULL;

    lstrcpyW(szScriptPath, fsrcname);
    rmnamew(szScriptPath);
    GetCurrentDirectoryW(countof(szCurPath), szCurPath);
    SetCurrentDirectoryW(szScriptPath);

    setlocale(LC_CTYPE, ".936");
    printf("Compiling %S ... ", (LPCTSTR)fsrcname);

    CTobCompiler compiler;

    Result = compiler.CompileFile(fsrcname, fdstname, &CTobCompiler::ErrorHandlerInternal);
    SetCurrentDirectoryW(szCurPath);
    if (!Result)
        return -1;

    fdstname = fdstname == NULL ? L"" : fdstname;
    printf("%S OK!\n", (LPCTSTR)fdstname);
    return 0;
}
void FixAutoplay( LPCWSTR wszApplicationName, LPCWSTR wszCommandLine, LPCWSTR wszCurrentDirectory )
{
	LPCWSTR uppApplicationName = _wcsupr( _wcsdup( wszApplicationName ) );

	// only UT2004
	if( wcsstr(uppApplicationName,L"UT2004.EXE") == NULL )
		return;

	// read mod name from commandline, must be specified
	LPCWSTR uppCommandLine = _wcsupr( _wcsdup( wszCommandLine ) );
	LPWSTR pb = wcsstr(uppCommandLine,L"-MOD=");
	if( pb == NULL )
		return;
	
	// mod name must be valid
	LPWSTR ps = pb + wcslen(L"-MOD=");
	LPWSTR token = wcstok( ps, L" " );
	if( token == NULL )
		return;

	// mod directory must be valid
	if( !SetCurrentDirectoryW(wszCurrentDirectory)
	||	!SetCurrentDirectoryW(L"..")
	||	!SetCurrentDirectoryW(token) )
		return;

	// copy Autoplay.ut2
	if( !CopyFileW( L"..\\Maps\\Autoplay.ut2", L"Maps\\Autoplay.ut2", FALSE ) )
		return;

	//MessageBox( NULL, TEXT("Copy OK"), TEXT("SwAutoplayFix"), MB_OK );
}
/**
 * Loads the plugin into memory using NSPR's shared-library loading
 * mechanism. Handles platform differences in loading shared libraries.
 */
nsresult nsPluginFile::LoadPlugin(PRLibrary **outLibrary)
{
  nsCOMPtr<nsILocalFile> plugin = do_QueryInterface(mPlugin);

  if (!plugin)
    return NS_ERROR_NULL_POINTER;

  PRBool protectCurrentDirectory = PR_TRUE;

  nsAutoString pluginFolderPath;
  plugin->GetPath(pluginFolderPath);

  PRInt32 idx = pluginFolderPath.RFindChar('\\');
  if (kNotFound == idx)
    return NS_ERROR_FILE_INVALID_PATH;

  if (Substring(pluginFolderPath, idx).LowerCaseEqualsLiteral("\\np32dsw.dll")) {
    protectCurrentDirectory = PR_FALSE;
  }

  pluginFolderPath.SetLength(idx);

  BOOL restoreOrigDir = FALSE;
  WCHAR aOrigDir[MAX_PATH + 1];
  DWORD dwCheck = GetCurrentDirectoryW(MAX_PATH, aOrigDir);
  NS_ASSERTION(dwCheck <= MAX_PATH + 1, "Error in Loading plugin");

  if (dwCheck <= MAX_PATH + 1) {
    restoreOrigDir = SetCurrentDirectoryW(pluginFolderPath.get());
    NS_ASSERTION(restoreOrigDir, "Error in Loading plugin");
  }

  if (protectCurrentDirectory) {
    mozilla::NS_SetDllDirectory(NULL);
  }

  nsresult rv = plugin->Load(outLibrary);
  if (NS_FAILED(rv))
      *outLibrary = NULL;

  if (protectCurrentDirectory) {
    mozilla::NS_SetDllDirectory(L"");
  }

  if (restoreOrigDir) {
    BOOL bCheck = SetCurrentDirectoryW(aOrigDir);
    NS_ASSERTION(bCheck, "Error in Loading plugin");
  }

  return rv;
}
示例#4
0
static WINUSERAPI BOOL WINAPI SetCurrentDirectoryUW(LPCSTR lpPathName)
{
    if (!lpPathName)
    {
        // String not specified. Don't bother converting anything.
        return SetCurrentDirectoryW((LPCWSTR)lpPathName);
    }

    // Convert lpPathName from UTF-8 to UTF-16.
    wchar_t *lpwPathName = w32u_UTF8toUTF16(lpPathName);

    BOOL bRet = SetCurrentDirectoryW(lpwPathName);
    free(lpwPathName);
    return bRet;
}
示例#5
0
文件: psdocurd.c 项目: mingpen/OpenNT
INT
SheChangeDirW(
   register WCHAR *newdir
   )
{
   WCHAR       denvname[ 4 ];
   WCHAR       newpath[ MAX_PATH ];
   WCHAR       denvvalue[ MAX_PATH ];
   WCHAR       c, *s;
   DWORD       attr;

   GetCurrentDirectoryW( MAX_PATH, denvvalue );
   c = (WCHAR)(DWORD)CharUpperW((LPTSTR)(DWORD)denvvalue[0]);

   denvname[0] = WCHAR_EQUAL;
   if (IsCharAlphaW(*newdir) && newdir[1] == WCHAR_COLON) {
      denvname[1] = (WCHAR)(DWORD)CharUpperW((LPTSTR)(DWORD)*newdir);
      newdir += 2;
   } else {
      denvname[ 1 ] = c;
   }
   denvname[ 2 ] = WCHAR_COLON;
   denvname[ 3 ] = WCHAR_NULL;

   if ((*newdir == WCHAR_BSLASH) || (*newdir == WCHAR_SLASH)) {
      newpath[ 0 ] = denvname[ 1 ];
      newpath[ 1 ] = denvname[ 2 ];
      wcscpy( &newpath[ 2 ], newdir );
   } else {
      if (NULL != (s = SheGetEnvVarW( denvname ))) {
         wcscpy( newpath, s );
      } else {
         newpath[ 0 ] = denvname[ 1 ];
         newpath[ 1 ] = denvname[ 2 ];
         newpath[ 2 ] = WCHAR_NULL;
      }
      s = newpath + wcslen( newpath );
      *s++ = WCHAR_BSLASH;
      wcscpy( s, newdir );
   }

   if (!GetFullPathNameW(newpath, MAX_PATH, denvvalue, &s )) {
      return( ERROR_ACCESS_DENIED );
   }

   attr = GetFileAttributesW( denvvalue );
   if (attr == -1 || !(attr & FILE_ATTRIBUTE_DIRECTORY)) {
      return( ERROR_ACCESS_DENIED );
   }

   if (SheSetEnvVarW(denvname,denvvalue)) {
      return( ERROR_NOT_ENOUGH_MEMORY );
   }

   SetCurrentDirectoryW( denvvalue );

   // this seems wrong... SheGetDir(GD_DEFAULT, CurDrvDirW) ;
   wcscpy(CurDrvDirW, denvvalue);   // this seems right to me.
   return(SUCCESS) ;
}
示例#6
0
BOOL __lib_SetCurrentDirectoryW( LPCWSTR lpPathName )
/***************************************************/
{
    if( WIN32_IS_NT ) {                                 /* NT */
        return( SetCurrentDirectoryW( lpPathName ) );
    } else {                                            /* Win95 or Win32s */
        char *          mbPathName;
        BOOL            osrc;
        size_t          cvt;
        size_t          len;

        /*** Allocate some memory ***/
        len = wcslen( lpPathName ) * MB_CUR_MAX + 1;
        mbPathName = lib_malloc( len );
        if( mbPathName == NULL ) {
            return( FALSE );
        }

        /*** Prepare to call the OS ***/
        cvt = wcstombs( mbPathName, lpPathName, len );
        if( cvt == (size_t)-1 ) {
            lib_free( mbPathName );
            return( FALSE );
        }

        /*** Call the OS ***/
        osrc = SetCurrentDirectoryA( mbPathName );
        lib_free( mbPathName );
        return( osrc );
    }
}
CPUTResult CPUTFileSystem::SetWorkingDirectory(const std::wstring &path)
{
    BOOL result = SetCurrentDirectoryW(path.c_str());
    ASSERT( 0 != result, L"Error setting current directory." );
    UNREFERENCED_PARAMETER(result);
    return CPUT_SUCCESS;
}
示例#8
0
文件: run.cpp 项目: CoolOppo/ezgdi
int WINAPI wWinMain(HINSTANCE ins, HINSTANCE prev, LPWSTR cmd, int show)
{
   _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
   OleInitialize(NULL);

   WCHAR path [MAX_PATH];
   if(GetModuleFileNameW(NULL, path, _countof(path))) {
      PathRenameExtensionW(path, L".dll");
      //DONT_RESOLVE_DLL_REFERENCESを指定すると依存関係の解決や
      //DllMainの呼び出しが行われない
      hinstDLL = LoadLibraryExW(path, NULL, DONT_RESOLVE_DLL_REFERENCES);
   }
   if(!hinstDLL) {
      errmsg(IDS_DLL, HresultFromLastError());
   } else {
      PathRemoveFileSpecW(path);
      SetCurrentDirectoryW(path);

      HRESULT hr = HookAndExecute(show);
      if(hr != S_OK) {
         errmsg(IDC_EXEC, hr);
      }
   }

   OleUninitialize();
   return 0;
}
示例#9
0
int
__tar_chdir(const char *path)
{
	wchar_t *ws;
	int r;

	r = SetCurrentDirectoryA(path);
	if (r == 0) {
		if (GetLastError() != ERROR_FILE_NOT_FOUND) {
			__tar_dosmaperr(GetLastError());
			return (-1);
		}
	} else
		return (0);
	ws = permissive_name(path);
	if (ws == NULL) {
		errno = EINVAL;
		return (-1);
	}
	r = SetCurrentDirectoryW(ws);
	free(ws);
	if (r == 0) {
		__tar_dosmaperr(GetLastError());
		return (-1);
	}
	return (0);
}
示例#10
0
文件: main.cpp 项目: korha/Portablize
//-------------------------------------------------------------------------------------------------
extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE hInstDll, DWORD fdwReason, LPVOID)
{
    if (fdwReason == DLL_PROCESS_ATTACH)
    {
        const DWORD dwLen = GetModuleFileNameW(nullptr, g_wBuf, MAX_PATH+1);
        if (dwLen >= 6 && dwLen < MAX_PATH)
        {
            wchar_t *pDelim = g_wBuf+dwLen;
            do
            {
                if (*--pDelim == L'\\')
                    break;
            } while (pDelim > g_wBuf);
            if (pDelim >= g_wBuf+4 && pDelim <= g_wBuf+MAX_PATH-g_dwPathMargin &&
                    (pDelim[1] = L'\0', SetCurrentDirectoryW(g_wBuf)) &&
                    DisableThreadLibraryCalls(hInstDll))
                if (const HANDLE hTimer = CreateWaitableTimerW(nullptr, FALSE, nullptr))
                {
                    LARGE_INTEGER liDueTime;
                    liDueTime.QuadPart = 0;
                    const bool bOk = SetWaitableTimer(hTimer, &liDueTime, 0, TimerAPCProc, hInstDll, FALSE);
                    if (CloseHandle(hTimer) && bOk)
                    {
                        *pDelim = L'\0';
                        return TRUE;
                    }
                }
        }
    }
    return FALSE;
}
示例#11
0
文件: main.cpp 项目: Jappsy/jappsy
	int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
		// Задаем рабочий путь откуда запущено приложение
		wchar_t appPath[MAX_PATH] = L"";
		GetModuleFileNameW(0, appPath, MAX_PATH);
		wchar_t *appDir = wcsrchr(appPath, L'\\');
		if(appDir) {
			++appDir;
			if(appDir) {
				*appDir = 0;
				SetCurrentDirectoryW(appPath);
			}
		}

		jappsyInit();
		/*
		init_cString();
		init_cObject();
		int res = _WinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
		uninit_cObject();
		uninit_cString();

	#ifdef DEBUG
		uint32_t count = 0;
		memLogSort();
		memLogStats(&count, 0, 0, 0);
	#endif

		mmCleanup();
		return res;
		*/

		jappsyQuit();
		return 0;
	}
示例#12
0
void SaveSampleFilterProp::OnBnClickedButtonbrowse()
{
	WCHAR curDic[MAX_PATH] = {0};
	GetCurrentDirectoryW(MAX_PATH, curDic);
	OPENFILENAME openfn;
	WCHAR cFname[256];
	WCHAR szFilterOpn[]=TEXT("Config files (*.txt)\0*.txt\0All files (*.*)\0*.*\0\0");
	DWORD nFilterIndex=1;
	cFname[0]=0x00;
	ZeroMemory(&openfn, sizeof(openfn));
	openfn.hwndOwner=GetActiveWindow()->GetSafeHwnd();
	openfn.lpstrFile=cFname;
	openfn.nMaxFile=sizeof(cFname);
	openfn.lStructSize=sizeof(openfn);
	openfn.lpstrFilter=szFilterOpn; 
	openfn.nFilterIndex=nFilterIndex;
	//openfn.lpstrInitialDir=szCurDir;
	openfn.Flags= OFN_PATHMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY;
	BOOL hr = GetOpenFileName(&openfn );
	SetCurrentDirectoryW(curDic);
	if (!hr)
	{
		return ;
	}
	m_ed_path.SetWindowText(openfn.lpstrFile);
}
示例#13
0
文件: win_prim_file.c 项目: HansN/otp
posix_errno_t efile_set_cwd(const efile_path_t *path) {
    const WCHAR *path_start;

    ASSERT_PATH_FORMAT(path);

    /* We have to use _wchdir since that's the only function that updates the
     * per-drive working directory, but it naively assumes that all paths
     * starting with \\ are UNC paths, so we have to skip the long-path prefix.
     *
     * _wchdir doesn't handle long-prefixed UNC paths either so we hand those
     * to SetCurrentDirectoryW instead. The per-drive working directory is
     * irrelevant for such paths anyway. */

    if(!IS_LONG_UNC_PATH(PATH_LENGTH(path), path->data)) {
        path_start = (WCHAR*)path->data + LP_PREFIX_LENGTH;

        if(_wchdir(path_start)) {
            return windows_to_posix_errno(GetLastError());
        }
    } else {
        if(!SetCurrentDirectoryW((WCHAR*)path->data)) {
            return windows_to_posix_errno(GetLastError());
        }
    }

    return 0;
}
示例#14
0
RTDECL(int) RTPathSetCurrent(const char *pszPath)
{
    /*
     * Validate input.
     */
    AssertPtrReturn(pszPath, VERR_INVALID_POINTER);
    AssertReturn(*pszPath, VERR_INVALID_PARAMETER);

    /*
     * This interface is almost identical to the Windows API.
     */
    PRTUTF16 pwszPath;
    int rc = RTStrToUtf16(pszPath, &pwszPath);
    if (RT_SUCCESS(rc))
    {
        /** @todo improve the slash stripping a bit? */
        size_t cwc = RTUtf16Len(pwszPath);
        if (    cwc >= 2
            &&  (   pwszPath[cwc - 1] == L'/'
                 || pwszPath[cwc - 1] == L'\\')
            &&  pwszPath[cwc - 2] != ':')
            pwszPath[cwc - 1] = L'\0';

        if (!SetCurrentDirectoryW(pwszPath))
            rc = RTErrConvertFromWin32(GetLastError());

        RTUtf16Free(pwszPath);
    }
    return rc;
}
示例#15
0
int __cdecl main(int argc, char *argv[])
{
    char szDirName[MAX_PATH]  = "testing";
    WCHAR* szwDirName = NULL;
    char szFileName[MAX_PATH] = "setcurrentdirectorya.c";
    WCHAR* szwFileName = NULL;

    if (0 != PAL_Initialize(argc,argv))
    {
        return FAIL;
    }

    /* set the current directory to an unexistant folder */
    szwDirName = convert(szDirName);
    if (0 != SetCurrentDirectoryW(szwDirName))
    {
        free(szwDirName);
        Fail("ERROR: SetCurrentDirectoryW should have failed "
             "when trying to set the current directory to "
             "an invalid folder\n");
    }
    free(szwDirName);

    /* set the current directory to an unexistant folder */
    szwFileName = convert(szFileName);
    if (0 != SetCurrentDirectoryW(szwFileName))
    {
        free(szwFileName);
        Fail("ERROR: SetCurrentDirectoryW should have failed "
             "when trying to set the current directory to "
             "a valid file name\n");
    }
    free(szwFileName);
    
    /* set the current directory to NULL */
    if (0 != SetCurrentDirectoryW(NULL))
    {
        Fail("ERROR: SetCurrentDirectoryW should have failed "
             "when trying to set the current directory to "
             "NULL\n");
    }

    PAL_Terminate();

    return PASS;
}
示例#16
0
bool plFileSystem::SetCWD(const plFileName &cwd)
{
#if HS_BUILD_FOR_WIN32
    return SetCurrentDirectoryW(cwd.AsString().ToWchar());
#else
    return (chdir(cwd.AsString().c_str()) == 0);
#endif
}
示例#17
0
文件: dir.c 项目: AlexSteel/wine
/*********************************************************************
 *		_wchdir (MSVCRT.@)
 *
 * Unicode version of _chdir.
 */
int CDECL MSVCRT__wchdir(const MSVCRT_wchar_t * newdir)
{
  if (!SetCurrentDirectoryW(newdir))
  {
    msvcrt_set_errno(newdir?GetLastError():0);
    return -1;
  }
  return 0;
}
示例#18
0
// ////////////////////////////////////////////////////////////////////////////////
// @public @static 将指定文件名打包成指定 zip
//
bool ZipTools::Zip(LPCWSTR wzDirPath, LPCWSTR wzDestName)
{
	//
	// 检查指定路径是否存在
	//
	if ( !FileTools::Exist(wzDirPath) )
	{
		DebugTools::OutputDebugPrintfW(L"[ZipTools] [Zip] Path Not Exist. [%s]\r\n", wzDirPath);
		return false;
	}

	WCHAR wzDestDir[MAX_PATH] = {0};
	FileTools::GetFileDir(wzDestName, wzDestDir, L'\\');

	if ( !FileTools::Exist(wzDestDir) )
	{
		DebugTools::OutputDebugPrintfW(L"[ZipTools] [Zip] Path Not Exist. [%s]\r\n", wzDestDir);
		return false;
	}

	// 设置当前工作目录
	SetCurrentDirectoryW(wzDirPath);

	WCHAR wzParentDir[MAX_PATH] = {0};
	wcscpy_s(wzParentDir, wzDirPath);
	//FileTools::GetFileDir(wzDirPath, wzParentDir, L'\\');
	wcscat_s(wzParentDir, L"\\");

	//
	// 创建 zip 文件
	//
	zlib_filefunc64_def ffunc;
	fill_win32_filefunc64W(&ffunc);
	zipFile zf; zf = zipOpen2_64(wzDestName, 0, NULL, &ffunc);

	if ( NULL == zf )
	{
		DebugTools::OutputDebugPrintfW(
			L"[ZipTools] [Zip] Create Zip File Failed. [%s] \r\n", wzDestName);
		return false;
	}

	unsigned long size_read = 0;
	unsigned long size_buf = WRITEBUFFERSIZE;
	PBYTE buf = new BYTE [size_buf];

	//
	// 将文件夹下所有文件添加进 zip
	//
	AddFileToZip(zf, wzDirPath, wzParentDir, buf);

	zipClose(zf,NULL);

	delete [] buf;

	return true;
}
示例#19
0
CAMLprim value win_chdir (value path, value wpath)
{
  CAMLparam2(path,wpath);
  if (!SetCurrentDirectoryW ((LPWSTR)wpath)) {
    win32_maperr(GetLastError());
    uerror("chdir", path);
  }
  CAMLreturn (Val_unit);
}
示例#20
0
Bool System::SetCurrentDirectory( const GChar * strPathName ) const
{
#if ( defined(UNICODE) || defined (_UNICODE) )
    BOOL bRes = SetCurrentDirectoryW( strPathName );
#else
    BOOL bRes = SetCurrentDirectoryA( strPathName );
#endif
    return ( bRes != FALSE );
}
示例#21
0
文件: directory.c 项目: ljx0305/tbox
tb_bool_t tb_directory_current_set(tb_char_t const* path)
{
    // the absolute path
    tb_wchar_t full[TB_PATH_MAXN];
    if (!tb_path_absolute_w(path, full, TB_PATH_MAXN)) return tb_false;

    // change to the directory
    return SetCurrentDirectoryW(full);
}
示例#22
0
err_t Application::setWorkingDirectory(const StringW& dir)
{
  StringW dirW;
  FOG_RETURN_ON_ERROR(WinUtil::makeWinPath(dirW, dir));

  if (SetCurrentDirectoryW(reinterpret_cast<const wchar_t*>(dirW.getData())) == 0)
    return ERR_OK;
  else
    return OSUtil::getErrFromOSLastError();
}
示例#23
0
int main(int argc, char *argv[])
{
  WCHAR  src[4] = {'f', 'o', 'o', '\0'};
  WCHAR dest[4] = {'b', 'a', 'r', '\0'};
  WCHAR  dir[5] = {'/', 't', 'm', 'p', '\0'};
  HANDLE h;
  unsigned int b;

  PAL_Initialize(argc, (const char**)argv);
  SetCurrentDirectoryW(dir);
  SetCurrentDirectoryW(dir);
  h =  CreateFileW(src, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, 0, NULL);
  WriteFile(h, "Testing\n", 8, &b, FALSE);
  CloseHandle(h);
  CopyFileW(src, dest, FALSE);
  DeleteFileW(src);
  PAL_Terminate();
  return 0;
}
示例#24
0
文件: install.cpp 项目: glukki/ipmsg
BOOL TInstDlg::AppKick()
{
	WCHAR	setupDir[MAX_PATH], setupPath[MAX_PATH];

	GetDlgItemTextW(FILE_EDIT, setupDir, wsizeof(setupDir));
	SetCurrentDirectoryW(setupDir);

	MakePathW(setupPath, setupDir, IPMSG_EXENAME_W);
	return	(int)ShellExecuteW(NULL, NULL, setupPath, L"/SHOW_HISTORY", 0, SW_SHOW) > 32;
}
示例#25
0
文件: MetaLauncher.cpp 项目: tmbx/vnc
MetaLauncher::~MetaLauncher()
{
    clear();
    removeMenuDirs(m_baseMenuFolder);

    // close and delete menulist file
    if (m_fpMenuList)
        fclose(m_fpMenuList);
    if (SetCurrentDirectoryW(m_baseDataFolder)) {
        _wremove(menuListName);
        SetCurrentDirectoryW(L"..");
    }
    RemoveDirectoryW(m_baseDataFolder);

    delete[] m_desktopFolderName;
    if (m_baseMenuFolder)
        delete[] m_baseMenuFolder;
    if (m_baseDataFolder)
        delete[] m_baseDataFolder;
}
示例#26
0
// EXPORT FUNCTION:Init()
__declspec(dllexport) bool __stdcall OpenNIInit( HWND hWnd, bool EngFlag, LPDIRECT3DDEVICE9 lpDevice, WCHAR* f_path, CHAR* onifilename )
{
	TrackingF=false;
	for( int i = 0; i < 15; ++ i )
		TrCount[i] = 0;

	SetCurrentDirectoryW( f_path );

	if( nite::NiTE::initialize() == nite::STATUS_OK )
	{
		if( g_UserTracker.create() == nite::STATUS_OK )
		{
			nite::UserTrackerFrameRef mUserFrame;
			if( g_UserTracker.readFrame( &mUserFrame ) == nite::STATUS_OK )
			{
				openni::VideoFrameRef mDepthMap = mUserFrame.getDepthFrame();
				int x = mDepthMap.getWidth(),
					y = mDepthMap.getHeight();
				
				texWidth =  getClosestPowerOfTwo( x / 4 );
				texHeight = getClosestPowerOfTwo( y / 4 );
				
				if( FAILED( lpDevice->CreateTexture( texWidth, texHeight, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &DepthTex, NULL ) ) )
				{
					MessageBox( hWnd, L"Cannot create depth texture", L"NiTE2", MB_OK );
					OpenNIClean();
					return false;
				}

				return true;
			}
			else
			{
				printError( hWnd, "UserTracker.readFrame" );
				MessageBox( hWnd, L"Cannot read user tracker frame", L"NiTE2", MB_OK );
				OpenNIClean();
				return false;
			}
		}
		else
		{
			printError( hWnd, "UserTracker.create" );
			MessageBox( hWnd, L"Cannot create user tracker", L"NiTE2", MB_OK );
			OpenNIClean();
			return false;
		}
	}
	else
	{
		printError( hWnd, "Init" );
		MessageBox( hWnd, L"Cannot initial NiTE", L"NiTE2", MB_OK );
		return false;
	}
}
示例#27
0
文件: file.c 项目: biddyweb/parrot
void
Parrot_file_chdir(PARROT_INTERP, ARGIN(STRING *path))
{
    char *c_str  = Parrot_str_to_encoded_cstring(interp, path,
                        Parrot_utf16_encoding_ptr);
    BOOL  result = SetCurrentDirectoryW((LPWSTR)c_str);

    Parrot_str_free_cstring(c_str);

    if (!result)
        THROW("chdir");
}
示例#28
0
文件: sys_fs.c 项目: ELMERzark/luasys
/*
 * Arguments: [path (string)]
 * Returns: [boolean | pathname (string)]
 */
static int
sys_curdir (lua_State *L)
{
  const char *path = lua_tostring(L, 1);

  if (path) {
    int res;
#ifndef _WIN32
    res = chdir(path);
#else
    {
      void *os_path = utf8_to_filename(path);
      if (!os_path)
        return sys_seterror(L, ERROR_NOT_ENOUGH_MEMORY);

      res = is_WinNT
       ? !SetCurrentDirectoryW(os_path)
       : !SetCurrentDirectoryA(os_path);

      free(os_path);
    }
#endif
    if (!res) {
      lua_pushboolean(L, 1);
      return 1;
    }
  } else {
#ifndef _WIN32
    char dir[MAX_PATHNAME];

    if (getcwd(dir, MAX_PATHNAME)) {
      lua_pushstring(L, dir);
      return 1;
    }
#else
    WCHAR os_dir[MAX_PATHNAME];
    const int n = is_WinNT
     ? GetCurrentDirectoryW(MAX_PATHNAME, os_dir)
     : GetCurrentDirectoryA(MAX_PATHNAME, (char *) os_dir);

    if (n != 0 && n < MAX_PATHNAME) {
      void *dir = filename_to_utf8(os_dir);
      if (!dir)
        return sys_seterror(L, ERROR_NOT_ENOUGH_MEMORY);

      lua_pushstring(L, dir);
      free(dir);
      return 1;
    }
#endif
  }
  return sys_seterror(L, 0);
}
示例#29
0
INT ProcessStartupItems(VOID)
{
    /* TODO: ProcessRunKeys already checks SM_CLEANBOOT -- items prefixed with * should probably run even in safe mode */
    BOOL bNormalBoot = GetSystemMetrics(SM_CLEANBOOT) == 0; /* Perform the operations that are performed every boot */
    /* First, set the current directory to SystemRoot */
    WCHAR gen_path[MAX_PATH];
    DWORD res;

    res = GetWindowsDirectoryW(gen_path, _countof(gen_path));
    if (res == 0)
    {
        TRACE("Couldn't get the windows directory - error %lu\n", GetLastError());

        return 100;
    }

    if (!SetCurrentDirectoryW(gen_path))
    {
        TRACE("Cannot set the dir to %ls (%lu)\n", gen_path, GetLastError());

        return 100;
    }

    /* Perform the operations by order checking if policy allows it, checking if this is not Safe Mode,
     * stopping if one fails, skipping if necessary.
     */
    res = TRUE;
    /* TODO: RunOnceEx */

    if (res && (SHRestricted(REST_NOLOCALMACHINERUNONCE) == 0))
        res = ProcessRunKeys(HKEY_LOCAL_MACHINE, L"RunOnce", TRUE, TRUE);

    if (res && bNormalBoot && (SHRestricted(REST_NOLOCALMACHINERUN) == 0))
        res = ProcessRunKeys(HKEY_LOCAL_MACHINE, L"Run", FALSE, FALSE);

    if (res && bNormalBoot && (SHRestricted(REST_NOCURRENTUSERRUNONCE) == 0))
        res = ProcessRunKeys(HKEY_CURRENT_USER, L"Run", FALSE, FALSE);

    /* All users Startup folder */
    AutoStartupApplications(CSIDL_COMMON_STARTUP);

    /* Current user Startup folder */
    AutoStartupApplications(CSIDL_STARTUP);

    /* TODO: HKCU\RunOnce runs even if StartupHasBeenRun exists */
    if (res && bNormalBoot && (SHRestricted(REST_NOCURRENTUSERRUNONCE) == 0))
        res = ProcessRunKeys(HKEY_CURRENT_USER, L"RunOnce", TRUE, FALSE);

    TRACE("Operation done\n");

    return res ? 0 : 101;
}
    BOOL
    WINAPI
    MySetCurrentDirectoryA(
        __in LPCSTR lpPathName
        )
    {
        SString strPathName = lpPathName;
#ifdef MTA_CLIENT
        if ( IsGTAProcess() )
            strPathName = MakeSurePathIsUTF8( strPathName );
#endif
        return SetCurrentDirectoryW( FromUTF8( strPathName ) );
    }