EDFBFont::EDFBFont(EDFBGraphicsEngine *dfbEngine, const char *filename) : EFontEngine(), fScalable(false), fForceFontAliasing(false), fFilename(NULL), fEngine(NULL) { if(dfbEngine == NULL) return; fEngine = dfbEngine; EAutolock <EDFBGraphicsEngine> autolock(fEngine); if(autolock.IsLocked() == false || fEngine->InitCheck() != E_OK) {fEngine = NULL; return;} DFBFontDescription fontdesc; fontdesc.flags = (DFBFontDescriptionFlags)(DFDESC_ATTRIBUTES | DFDESC_HEIGHT); fontdesc.attributes = DFFA_NONE; fontdesc.height = ETK_DIRECTFONT_DEFAULT_SIZE; if(fEngine->dfbDisplay->CreateFont(fEngine->dfbDisplay, filename, &fontdesc, &fDFBFont) != DFB_OK) { ETK_DEBUG("[FONT]: CreateFont(%s) failed.", filename); fEngine = NULL; return; } EPath aPath(filename); if(aPath.Path() != NULL) fFilename = EStrdup(aPath.Path()); SetFamily(aPath.Leaf() ? aPath.Leaf() : "DFB-Default"); SetStyle("Regular"); int height = 0; fDFBFont->GetHeight(fDFBFont, &height); float sizes = (float)height; SetFixedSize(&sizes, 1); SetRenderMode(E_FONT_RENDER_DIRECTLY); }
void ZipLocalFileHeader::setFileName(const std::string& fileName, bool isDirectory) { poco_assert (!fileName.empty()); Poco::Path aPath(fileName); if (isDirectory) { aPath.makeDirectory(); setCRC(0); setCompressedSize(0); setUncompressedSize(0); setCompressionMethod(ZipCommon::CM_STORE); setCompressionLevel(ZipCommon::CL_NORMAL); } else { aPath.makeFile(); } _fileName = aPath.toString(Poco::Path::PATH_UNIX); if (_fileName[0] == '/') _fileName = _fileName.substr(1); if (isDirectory) { poco_assert_dbg (_fileName[_fileName.size()-1] == '/'); } setFileNameLength(static_cast<Poco::UInt16>(_fileName.size())); }
TEST(FileSystem, PathToDirectoryNotFound) { filesystem::Path aPath("test099"); EXPECT_FALSE(aPath.exists()); EXPECT_FALSE(aPath.isDirectory()); EXPECT_FALSE(aPath.isFile()); }
TEST(FileSystem, ExistingFileOpenClose) { filesystem::Path aPath("test/dummy.txt"); filesystem::File * aFile = new filesystem::File(aPath); EXPECT_TRUE(aFile->isValid()); delete aFile; }
TEST(FileSystem, PathToFileNotFound) { filesystem::Path aPath("test/dummy099.txt"); EXPECT_FALSE(aPath.exists()); EXPECT_FALSE(aPath.isDirectory()); EXPECT_FALSE(aPath.isFile()); }
void aPath(TreeNode* root, vector<int> temp, vector<vector <int> > &v, int sum){ if(root==NULL){ return ; } temp.push_back(root->val); if(root->left == NULL && root->right == NULL && sum==root->val){ v.push_back(temp); temp.clear(); return; } aPath(root->left, temp, v, sum - root->val); aPath(root->right, temp, v, sum - root->val); }
TEST(FileSystem, ReadFileIntoString) { filesystem::Path aPath("test/dummy.txt"); filesystem::File aFile(aPath); EXPECT_TRUE(aFile.isValid()); std::string aTarget; EXPECT_TRUE(aFile.read(aTarget)); EXPECT_EQ("this is a nice first line,./aa\nthis is a proper second line....\n\nafter the previous empty line this is number 4\n\n6\n\n", aTarget); }
int main(int argc, char **argv) { EPath aPath(argv[0]); ETK_OUTPUT("usage: %s [IP Address]\n", aPath.Leaf()); if(argc == 1) server(); else client(argv[1]); return 0; }
std::string File::GetFileFromFilePath( char const * path ) { std::string aPath(path); std::string aFilename; const size_t pos = aPath.find_last_of("\\/"); if (pos != std::string::npos) { aFilename.assign(aPath.begin() + pos + 1, aPath.end()); } else { aFilename = aPath; } return aFilename.c_str(); }
TEST(FileSystem, ReadFileIntoVectorOfString) { filesystem::Path aPath("test/dummy.txt"); filesystem::File aFile(aPath); EXPECT_TRUE(aFile.isValid()); std::vector<std::string> aTarget; EXPECT_TRUE(aFile.readLines(aTarget)); EXPECT_EQ(aTarget.size(), (unsigned)8); EXPECT_EQ(aTarget[0], "this is a nice first line,./aa"); EXPECT_EQ(aTarget[1], "this is a proper second line...."); EXPECT_EQ(aTarget[2], ""); EXPECT_EQ(aTarget[3], "after the previous empty line this is number 4"); EXPECT_EQ(aTarget[4], ""); EXPECT_EQ(aTarget[5], "6"); EXPECT_EQ(aTarget[6], ""); EXPECT_EQ(aTarget[7], ""); }
bool BEntry::IsHidden() const { bool retVal = false; BPath aPath(fName); const char *leaf = aPath.Leaf(); if (!(leaf == NULL || *leaf != '.')) retVal = true; #ifdef _WIN32 BString str(fName); str.ReplaceAll("/", "\\"); if (GetFileAttributes(str.String()) & FILE_ATTRIBUTE_HIDDEN) retVal = true; #endif return retVal; }
void BezierCurveItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { painter->setRenderHint(QPainter::Antialiasing, true); QPen pen; pen.setColor(Qt::red); pen.setWidth(2); pen.setStyle(Qt::DashDotLine); painter->setPen(pen); //drawPath; QPainterPath aPath(m_startPos); aPath.quadTo(m_midStartPos, m_midPos); painter->drawPath(aPath); QPainterPath bPath(m_midPos); bPath.quadTo(m_midEndPos, m_endPos); painter->drawPath(bPath); QPen penshaper; penshaper.setStyle(Qt::SolidLine); penshaper.setColor(Qt::darkRed); painter->setPen(penshaper); //#define the rect size; QSize rect_size(60, 60); QRect rect_shape1(m_startPos - QPoint(rect_size.height() / 2, rect_size.width() / 2), rect_size); QRect rect_shape2(m_endPos - QPoint(rect_size.height() / 2, rect_size.width() / 2), rect_size); QBrush brush(Qt::darkGray, Qt::CrossPattern); painter->fillRect(rect_shape1, brush); painter->fillRect(rect_shape2, brush); painter->drawRoundedRect(rect_shape1, 10, 10); painter->drawRoundedRect(rect_shape2, 10, 10); QPen dotpen; dotpen.setWidth(8); dotpen.setColor(Qt::red); brush.setStyle(Qt::SolidPattern); painter->setPen(dotpen); painter->drawPoint(m_startPos); painter->drawPoint(m_endPos); }
Sample2D_Image::Sample2D_Image(Standard_CString& aFileName, const Quantity_Length X, // = 0.0 const Quantity_Length Y, // = 0.0 const Quantity_Length adx, // = 0.0 const Quantity_Length ady, // = 0.0 const Aspect_CardinalPoints aTypeOfPlacement,// = Aspect_CP_Center const Quantity_Factor aScale) // = 1.0) :AIS2D_InteractiveObject() { TCollection_AsciiString TheDependentName(aFileName); OSD_Path aPath(TheDependentName); OSD_File aFile(aPath); myFile = aFile ; myX = X ; myY = Y ; myDx = adx ; myDy = ady ; myTypeOfPlacement = aTypeOfPlacement ; myScale = aScale ; //Attach a graphic view to this object }
e_status_t EDirectory::SetTo(const char *path) { if(path == NULL) return E_BAD_VALUE; EPath aPath(path, NULL, true); if(aPath.Path() == NULL) return E_ENTRY_NOT_FOUND; char *name = EStrdup(aPath.Path()); if(name == NULL) return E_NO_MEMORY; e_status_t retVal = E_FILE_ERROR; const char *dirname = aPath.Path(); #ifdef _WIN32 EString str(dirname); str.ReplaceAll("/", "\\"); dirname = str.String(); #endif // _WIN32 do { #ifdef HAVE_DIRENT_H struct stat statBuf; if(stat(dirname, &statBuf) != 0) break; if(!S_ISDIR(statBuf.st_mode)) {retVal = E_ENTRY_NOT_FOUND; break;} DIR *dir = opendir(dirname); if(dir == NULL) break; if(fDir != NULL) closedir((DIR*)fDir); fDir = dir; retVal = E_OK; #else #ifdef _WIN32 DWORD attr = GetFileAttributes(dirname); if(attr == (DWORD)-1/*INVALID_FILE_ATTRIBUTES*/) break; if(!(attr & FILE_ATTRIBUTE_DIRECTORY)) {retVal = E_ENTRY_NOT_FOUND; break;} if(fDir == NULL) { if((fDir = malloc(sizeof(etk_win32_dir_t))) == NULL) {retVal = E_NO_MEMORY; break;} bzero(fDir, sizeof(etk_win32_dir_t)); } else { if(((etk_win32_dir_t*)fDir)->findHandle != INVALID_HANDLE_VALUE) FindClose(((etk_win32_dir_t*)fDir)->findHandle); } str.Append("\\*"); const char *searchName = str.String(); ((etk_win32_dir_t*)fDir)->first = true; ((etk_win32_dir_t*)fDir)->findHandle = FindFirstFile(searchName, &(((etk_win32_dir_t*)fDir)->findData)); retVal = E_OK; #else #warning "fixme: EDirectory::SetTo" #endif // _WIN32 #endif // HAVE_DIRENT_H } while(false); if(retVal != E_OK) { delete[] name; return retVal; } if(fName != NULL) delete[] fName; fName = name; return E_OK; }
e_status_t EDirectory::GetNextEntry(EEntry *entry, bool traverse) { if(entry == NULL) return E_BAD_VALUE; if(fName == NULL || fDir == NULL) {entry->Unset(); return E_FILE_ERROR;} e_status_t retVal = E_FILE_ERROR; #ifdef HAVE_DIRENT_H while(true) { struct dirent *dirEntry = readdir((DIR*)fDir); if(dirEntry == NULL) {retVal = E_ENTRY_NOT_FOUND; break;} if(strlen(dirEntry->d_name) == 1 && dirEntry->d_name[0] == '.') continue; if(strlen(dirEntry->d_name) == 2 && strcmp(dirEntry->d_name, "..") == 0) continue; EPath aPath(fName, dirEntry->d_name, true); #if defined(S_ISLNK) if(aPath.Path() != NULL && traverse) { struct stat statBuf; if(lstat(aPath.Path(), &statBuf) == 0 && S_ISLNK(statBuf.st_mode)) { char buf[E_MAXPATH + 1]; bzero(buf, E_MAXPATH + 1); if(readlink(aPath.Path(), buf, E_MAXPATH) > 0) { // ETK_DEBUG("[STORAGE]: link is %s", buf); if(buf[0] != '/') aPath.SetTo(fName, buf, true); else aPath.SetTo(buf, NULL, true); } else { // ETK_DEBUG("[STORAGE]: CAN'T read link %s", aPath.Path()); aPath.Unset(); retVal = E_LINK_LIMIT; } } } #else #warning "fixme: NO S_ISLNK" #endif // S_ISLNK if(aPath.Path() == NULL) continue; char *name = EStrdup(aPath.Path()); if(name == NULL) {retVal = E_NO_MEMORY; break;} if(entry->fName != NULL) delete[] entry->fName; entry->fName = name; retVal = E_OK; break; } #else #ifdef _WIN32 if(((etk_win32_dir_t*)fDir)->findHandle == INVALID_HANDLE_VALUE) retVal = E_ENTRY_NOT_FOUND; else while(true) { if(((etk_win32_dir_t*)fDir)->first) { ((etk_win32_dir_t*)fDir)->first = false; } else { if(FindNextFile(((etk_win32_dir_t*)fDir)->findHandle, &(((etk_win32_dir_t*)fDir)->findData)) == 0) {retVal = E_ENTRY_NOT_FOUND; break;} } const char *filename = ((etk_win32_dir_t*)fDir)->findData.cFileName; if(filename[0] == '.' && (filename[1] == 0 || (filename[1] == '.' && filename[2] == 0))) continue; EPath aPath(fName, filename, true); if(aPath.Path() == NULL) continue; char *name = EStrdup(aPath.Path()); if(name == NULL) {retVal = E_NO_MEMORY; break;} if(entry->fName != NULL) delete[] entry->fName; entry->fName = name; retVal = E_OK; break; }; #else #warning "fixme: EDirectory::GetNextEntry" #endif // _WIN32 #endif // HAVE_DIRENT_H if(retVal != E_OK) entry->Unset(); return retVal; }
vector<vector<int> > Solution::pathSum(TreeNode* root, int sum) { vector <vector<int> > v; vector <int> temp; aPath(root, temp, v, sum); return v; }