bool ProjectGenerator::CopyDirectory(const nglPath& targetPath, const nglPath& srcpath) { // create folder if (!targetPath.Create()) { nglString msg; msg.Format(_T("creating target folder '%ls'"), targetPath.GetChars()); return MsgError(msg); } std::list<nglPath> children; srcpath.GetChildren(&children); std::list<nglPath>::iterator it; for (it = children.begin(); it != children.end(); ++it) { const nglPath& srcpath = *it; if (!srcpath.IsLeaf()) continue; nglPath dstpath = targetPath; dstpath += srcpath.GetNodeName(); nglString contents; nglIStream* piFile = srcpath.OpenRead(); if (!piFile) { nglString msg; msg.Format(_T("opening for reading input file '%ls'"), srcpath.GetChars()); return MsgError(msg); } nglOStream* poFile = dstpath.OpenWrite(false); if (!poFile) { nglString msg; msg.Format(_T("opening for writing output file '%ls'"), dstpath.GetChars()); return MsgError(msg); } piFile->PipeTo(*poFile); delete poFile; delete piFile; NGL_OUT(_T("nui project generator : created file '%ls'\n"), dstpath.GetChars()); } return true; }
bool MainWindow::LoadCSS(const nglPath& rPath) { NGL_OUT("MainWindow::LoadCSS"); nglIStream* pF = rPath.OpenRead(); if (!pF) { NGL_OUT(_T("Unable to open CSS source file '%ls'\n"), rPath.GetChars()); return false; } nuiCSS* pCSS = new nuiCSS(); bool res = pCSS->Load(*pF, rPath); delete pF; if (res) { nuiMainWindow::SetCSS(pCSS); NGL_OUT("MainWindow::LoadCSS OK"); return true; } NGL_OUT(_T("%ls\n"), pCSS->GetErrorString().GetChars()); delete pCSS; NGL_OUT("MainWindow::LoadCSS ERROR"); return false; }
bool ProjectGenerator::GenerateFile(const nglPath& src, const nglPath& dst) { uint32 srcsize = (uint32)src.GetSize(); nglIStream* pFile = src.OpenRead(); if (!pFile) { nglString msg; msg.Format(_T("reading input file '%ls'"), src.GetChars()); return MsgError(msg); } char* str = new char[srcsize + 1]; pFile->Read(str, srcsize, 1); str[srcsize] = 0; delete pFile; nglString contents(str); contents.Replace(_T("TemplateApp"), mProjectName); contents.Replace(_T("../../../nui3"), mNuiRelativeSource.GetPathName()); nglOStream* poFile = dst.OpenWrite(false); if (!poFile) { nglString msg; msg.Format(_T("writing output file '%ls'"), dst.GetChars()); return MsgError(msg); } char* ptr = contents.Export(); poFile->Write(ptr, contents.GetLength(), 1); delete poFile; if (ptr) free(ptr); NGL_OUT(_T("nui project generator : generated '%ls'\n"), dst.GetChars()); return true; }
bool iOSDevice::InstallApplication(const nglPath& rPath) { AMDeviceConnect(mpDevice); bool paired = AMDeviceIsPaired(mpDevice); bool validated = AMDeviceValidatePairing(mpDevice) == 0; bool sessionstarted = AMDeviceStartSession(mpDevice) == 0; //if (paired && validated && sessionstarted) { CFStringRef path = CFStringCreateWithCString(NULL, rPath.GetChars(), kCFStringEncodingUTF8); CFURLRef relative_url = CFURLCreateWithFileSystemPath(NULL, path, kCFURLPOSIXPathStyle, false); CFURLRef url = CFURLCopyAbsoluteURL(relative_url); CFRelease(relative_url); service_conn_t afcFd; bool servicestarted = (AMDeviceStartService(mpDevice, CFSTR("com.apple.afc"), &afcFd, NULL) == 0); (AMDeviceStopSession(mpDevice) == 0); (AMDeviceDisconnect(mpDevice) == 0); (AMDeviceTransferApplication(afcFd, path, NULL, &iOSDevice::TransferCallback, (void*)this) == 0); close(afcFd); CFStringRef keys[] = { CFSTR("PackageType") }; CFStringRef values[] = { CFSTR("Developer") }; CFDictionaryRef options = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); AMDeviceConnect(mpDevice); (AMDeviceIsPaired(mpDevice)); (AMDeviceValidatePairing(mpDevice) == 0); (AMDeviceStartSession(mpDevice) == 0); service_conn_t installFd; (AMDeviceStartService(mpDevice, CFSTR("com.apple.mobile.installation_proxy"), &installFd, NULL) == 0); (AMDeviceStopSession(mpDevice) == 0); (AMDeviceDisconnect(mpDevice) == 0); mach_error_t result = AMDeviceInstallApplication(installFd, path, options, InstallCallback, (void*)this); if (result != 0) { printf("AMDeviceInstallApplication failed: %d\n", result); nglString str; str.CFormat("AMDeviceInstallApplication failed: %d", result); InstallationProgress(0, str); return false; } close(installFd); CFRelease(path); CFRelease(options); NGL_OUT("[100%%] Installed package %s\n", rPath.GetChars()); nglString str; str.CFormat("Installed package %s", rPath.GetChars()); InstallationProgress(100, str); return true; } return false; }
void nuiImageDecoration::SetTexturePath(nglPath path) { SetProperty(_T("Texture"), path.GetPathName()); nuiTexture* pOld = mpTexture; mpTexture = nuiTexture::GetTexture(path); if (!mpTexture || !mpTexture->IsValid()) { NGL_OUT(_T("nuiImageDecoration::SetTexturePath warning : could not load graphic resource '%ls'\n"), path.GetChars()); return; } if (GetSourceClientRect() == nuiRect(0,0,0,0)) SetSourceClientRect(nuiRect(0, 0, mpTexture->GetWidth(), mpTexture->GetHeight())); if (pOld) pOld->Release(); SetRepeatX(mRepeatX); SetRepeatY(mRepeatY); Changed(); }
void nuiFrame::SetTexturePath(const nglPath& rPath) { mTexturePath = rPath; nuiTexture* pOld = mpTexture; mpTexture = nuiTexture::GetTexture(rPath); if (!mpTexture || !mpTexture->IsValid()) { NGL_OUT(_T("nuiFrame::SetTexturePath warning : could not load graphic resource '%ls'\n"), rPath.GetChars()); return; } if (GetSourceClientRect() == nuiRect(0,0,0,0)) SetSourceClientRect(nuiRect(0, 0, mpTexture->GetWidth(), mpTexture->GetHeight())); if (pOld) pOld->Release(); if (mInterpolated) { mpTexture->SetMinFilter(GL_LINEAR); mpTexture->SetMagFilter(GL_LINEAR); } else { mpTexture->SetMinFilter(GL_NEAREST); mpTexture->SetMagFilter(GL_NEAREST); } Changed(); }