bool Demo_2::prepare() { if(!font.loadFromFile(file_rel("Minecraftia.ttf"))) { LOGE("Couldn't load font from file!"); return false; } imageinfo.setFont(font); imageinfo.setCharacterSize(15); imageinfo.setColor(sf::Color::White); imageinfo.setPosition(sf::Vector2f(xoff, yoff+28*boxsize+10)); fileindex = 1; loadFile(fileindex); imageindex = 1; setImage(imageindex); updateInfoText(); frameTime = 0; win.create(sf::VideoMode::getDesktopMode(), "DEMO 2", sf::Style::Fullscreen); win.setFramerateLimit(60); surround.append(sf::Vertex(sf::Vector2f(xoff, yoff))); surround.append(sf::Vertex(sf::Vector2f(xoff + 28*boxsize, yoff))); surround.append(sf::Vertex(sf::Vector2f(xoff + 28*boxsize, yoff + 28*boxsize))); surround.append(sf::Vertex(sf::Vector2f(xoff, yoff + 28*boxsize))); surround.append(sf::Vertex(sf::Vector2f(xoff, yoff))); surround.setPrimitiveType(sf::LinesStrip); return true; }
void Demo_2::loadFile(int n) { file.open(file_rel(STREAM("data" << n)), std::ios::binary); std::streampos filesize; file.seekg(0, std::ios::end); filesize = file.tellg(); file.seekg(0, std::ios::beg); data.clear(); data.resize(filesize); file.read((char*)&data[0], filesize); file.close(); }
int copy(int pc, paramv_t *pv) { extern char *Usercode; extern int Noupdt; register int i, pid; register char *cp; int stat; int op; #ifdef xZTR1 if (tTf(30,1)) { printf("entered copy\n"); prvect(pc, pv); } #endif Duptuple = 0; Truncount = 0; Tupcount = 0; Baddoms = 0; Relname = pv[0].pv_val.pv_str; Into = (pv[pc-2].pv_val.pv_str[0] == 'i'); Filename = pv[pc-1].pv_val.pv_str; /* relation must exist and not be a system relation */ /* in addition a copy "from" can't be done if the user */ /* doesn't own the relation */ /* and furthermore it can't have an index */ i = 0; /* assume all is well */ if ((op = openr(&Des, OR_WRITE, Relname)) != 0) { if (op == AMOPNVIEW_ERR) i = NOCPVIEW; else { if (op < 0) syserr("COPY: openr 1 (%.14s) %d", Relname, op); else /* non-existant relation */ i = NOEXIST; } } else { if (Into) { if ((Des.d_r.r_status & S_PROTALL) && (Des.d_r.r_status & S_PROTRET) && !bequal(Usercode, Des.d_r.r_owner, USERCODE_SIZE)) i = RELPROTECT; } else { /* extra checking if this is a copy "from" */ /* must be owned by the user */ if (!bequal(Usercode, Des.d_r.r_owner, USERCODE_SIZE)) i = NOTOWNER; else /* must be updateable */ if ((Des.d_r.r_status & S_NOUPDT) && Noupdt) i = NOUPDT; else /* must not be indexed */ if (Des.d_r.r_indexed > 0) i = DESTINDEX; } } if (i) { closer(&Des); return (error(i, Relname, 0)); /* relation doesn't exist for this user */ } /* check that file name begins with a "/" */ cp = Filename; while (*cp == ' ') cp++; if (*cp != '/') { closer(&Des); return (error(FULLPATH, Filename, 0)); } /* fill map structures with transfer information */ if ((i = mapfill(&pv[1])) != 0) { closer(&Des); return (i); /* error in user semantics */ } /* fork a child process which will run as the real user */ /* that child will complete the copy and exit */ if (pipe(Piped)) syserr("copy:can't make pipe"); if ((pid = fork()) < 0) syserr("copy:can't fork"); if (pid) { /* the ingres parent */ close(Piped[1]); ruboff(0); /* interrupts off */ stat = fullwait(pid, "copy"); if (read(Piped[0], &Des.d_addc, 4) != 4) syserr("copy:can't read pipe"); close(Piped[0]); closer(&Des); /* close the rel */ rubon(); /* if stat is != 0 then add on 5800 for error */ if (stat) stat += 5800; return (stat); /* done */ } /* the child. change to run as the real user */ if (signal(SIGINT, SIG_IGN) != SIG_IGN) { signal(SIGINT, copydone); /* clean up on rubout */ } setuid(getuid()); setgid(getgid()); if (Into) { /* from relation into file */ if ((File_iop = fopen(Filename, "w")) == NULL) /* create file for user */ i = nferror(NOFILECRT, Filename, 0); /* cant create file */ else { if (Lockrel) /* set a shared lock on relation*/ setrll(A_SLP, &Des.d_tid, M_SHARE); i = rel_file(); } } else { /* from UNIX file into relation */ if ((File_iop = fopen(Filename, "r")) == NULL) i = nferror(NOFILEOPN, Filename, 0); /* cant open user file */ else { if (Lockrel) /* set an exclusive lock on relat*/ setrll(A_SLP, &Des.d_tid, M_EXCL); i = file_rel(); if (Duptuple) nferror(DUPTUPS, locv(Duptuple), 0); /* warning only */ if (Baddoms) nferror(BADDOMS, locv(Baddoms), 0); /* warning only */ } } copydone(i); return(0); }