void cp2(char filename1[],char filename2[]) { char path2[256]; char path1[256]; strcat(path2,filename2); strcat(path1,filename1); DIR* dir=opendir(filename1); chdir(filename1); if(dir!=NULL) { struct dirent *ent=NULL; struct stat buf; ent=readdir(dir); while(ent!=NULL) { if(strcmp(ent->d_name,".")!=0 && strcmp(ent->d_name,"..")!=0) { stat(ent->d_name,&buf); if(S_ISDIR(buf.st_mode)) { chdir(path2); cp3(ent->d_name,1,0); strcat(path2,"/"); strcat(path2,ent->d_name); chdir(path1); strcat(path1,"/"); strcat(path1,ent->d_name); cp2(ent->d_name,NULL); } else { char c[1]; int fd=open(ent->d_name,O_RDWR); int ret=1; while(ret!=0) { ret=read(fd,c,sizeof(c)); chdir(path2); cp3(ent->d_name,2,c); } close(fd); } } ent=readdir(dir); } chdir(".."); cp3("..",1,0); } }
// Construct a Line NURBS by changing space dimension and ordering of //coordinates. MGRSBRep::MGRSBRep( size_t dim, // New space dimension. const MGRSBRep& rsb,// Original Surface B-rep. size_t start1, // Destination order of new line. size_t start2) // Source order of original line. :MGSurface(rsb){ update_mark(); size_t dim0=rsb.sdim(); MGSPointSeq cp1(dim0,rsb.surface_bcoef());//Exclude weights. MGSPointSeq cp2(dim,cp1,start1,start2); //Change order of coordinates. MGSPointSeq cp3(dim+1,cp2); //Get area for weights. for(size_t i=0; i<cp3.length_u(); i++) for(size_t j=0; j<cp3.length_v(); j++) cp3(i,j,dim)=rsb.surface_bcoef()(i,j,dim0);//Set weights. m_surface=MGSBRep(cp3,rsb.knot_vector_u(),rsb.knot_vector_v()); }
int main(int argc, char const *argv[]) { int n; printf("复制文件还是目录? 文件输入:1 目录输入:2\n"); scanf("%d",&n); if(n==1) { char filename1[128]; char filename2[128]; printf("请输入你想复制的文件名!\n"); scanf("%s",&filename1); printf("请输入你复制后的文件名!\n"); scanf("%s",&filename2); cp1(filename1,filename2); } else if(n==2) { char filename1[128]; char filename2[128]; printf("请输入你想复制的目录名!\n"); scanf("%s",&filename1); printf("请输入你复制后的目录名!\n"); scanf("%s",&filename2); cp3(filename2,1,0); cp2(filename1,filename2); } else { printf("输入有误 请重新运行后输入\n"); } return 0; }
//Changing this object's space dimension. MGRSBRep& MGRSBRep::change_dimension( size_t dim, // new space dimension size_t start1, // Destination order of new object. size_t start2) // Source order of this object. { size_t dim0=sdim(); MGSPointSeq cp1(dim0,surface_bcoef()); //Exclude weights. MGSPointSeq cp2(dim,cp1,start1,start2); //Change order of coordinates. MGSPointSeq cp3(dim+1,cp2); //Get area for weights. const MGSPointSeq& sp=surface_bcoef(); for(size_t i=0; i<cp3.length_u(); i++) for(size_t j=0; j<cp3.length_v(); j++) cp3(i,j,dim)=sp(i,j,dim0);//Set weights. m_surface=MGSBRep(cp3,knot_vector_u(),knot_vector_v()); update_mark(); return *this; }
void CCue::PaintPointer(CPaintDC* dc, int l) { COLORREF blue = RGB(0, 103, 223); CFlowZap *fc = ((CFlowZap*)m_Parent); try { CPen *oldPen; CBrush *oldBrush; CPen cp; CBrush cb; // if the user is dragging : red if (m_dragging) { cp.CreatePen(PS_SOLID, 1, COLORREF(0x0000ff)); oldPen = dc->SelectObject(&cp); cb.CreateSolidBrush(COLORREF(0x0000ff)); oldBrush = dc->SelectObject(&cb); } // if the user is running a program: green else if (fc->m_ProgramMode == pmExecute) { cp.CreatePen(PS_SOLID, 1, COLORREF(0x00ff00)); oldPen = dc->SelectObject(&cp); cb.CreateSolidBrush(COLORREF(0x00ff00)); oldBrush = dc->SelectObject(&cb); } // otherwise blue else { cp.CreatePen(PS_SOLID, 1, blue); oldPen = dc->SelectObject(&cp); cb.CreateSolidBrush(blue); oldBrush = dc->SelectObject(&cb); } vertices[0].x = 7; vertices[0].y = l - 5; vertices[1].x = 7; vertices[1].y = l + 5; vertices[2].x = 17; vertices[2].y = l + 5; vertices[3].x = 23; vertices[3].y = l; vertices[4].x = 17; vertices[4].y = l - 5; dc->Polygon(vertices, 5); CPen cp2(PS_SOLID, 1, COLORREF(0xffffff)); dc->SelectObject(&cp2); dc->MoveTo(7, l - 4); dc->LineTo(17, l - 4); dc->LineTo(22, l - 1); CPen cp3(PS_SOLID, 1, COLORREF(0x000000)); dc->SelectObject(&cp3); dc->MoveTo(7, l + 4); dc->LineTo(17, l + 4); dc->LineTo(22, l + 1); dc->SelectObject(oldPen); dc->SelectObject(oldBrush); cp.DeleteObject(); cb.DeleteObject(); cp2.DeleteObject(); cp3.DeleteObject(); } catch (CResourceException e) { int i = 0; } }
void test02() { // Tests for CIMConstProperty methods CIMProperty p1(CIMName ("message"), String("Hi There")); p1.addQualifier(CIMQualifier(CIMName ("Key"), true)); p1.addQualifier(CIMQualifier(CIMName ("stuff"), true)); p1.addQualifier(CIMQualifier(CIMName ("stuff2"), true)); p1.addQualifier(CIMQualifier(CIMName ("Description"), String("Blah Blah"))); CIMConstProperty p2 = p1; CIMConstProperty cp1 = p1; CIMConstProperty cp2 = p2; CIMConstProperty cp3(CIMName ("message3"), String("hello")); CIMConstProperty cp1clone = cp1.clone(); if(verbose) XmlWriter::printPropertyElement(cp1, cout); Buffer mofOut; MofWriter::appendPropertyElement(true,mofOut, cp1); Buffer xmlOut; XmlWriter::appendPropertyElement(xmlOut, cp1); PEGASUS_TEST_ASSERT(cp1.getName() == CIMName ("message")); PEGASUS_TEST_ASSERT(cp1.getType() == CIMTYPE_STRING); Uint32 pos; Boolean isKey = false; if ((pos = cp1.findQualifier (CIMName ("key"))) != PEG_NOT_FOUND) { CIMValue value; value = cp1.getQualifier (pos).getValue (); if (!value.isNull ()) { value.get (isKey); } } PEGASUS_TEST_ASSERT (isKey); PEGASUS_TEST_ASSERT(cp1.getArraySize() == 0); PEGASUS_TEST_ASSERT(cp1.getPropagated() == false); PEGASUS_TEST_ASSERT(cp1.findQualifier( CIMName ("stuff")) != PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(cp1.findQualifier( CIMName ("stuff2")) != PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(cp1.findQualifier( CIMName ("stuff21")) == PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(cp1.findQualifier( CIMName ("stuf")) == PEG_NOT_FOUND); PEGASUS_TEST_ASSERT(cp1.getQualifierCount() == 4); try { p1.getQualifier(0); } catch(IndexOutOfBoundsException& e) { if(verbose) cout << "Exception: " << e.getMessage() << endl; } }