// retrieves the data from the server - control path void d_retr(char **params, short *abor, int fd, struct state *cstate, struct config *configuration) { int accepted, retcode, file, r, subn = 0; char filepath[PATH_LENGTH], buf[2 * BUFSIZE]; // accepts / connects to the client if (spawnConnection(cstate, &accepted)) { retcode = 5; write(fd, &retcode, sizeof (int)); return; } // loads filepath of the given file readUntil(filepath, fd, 0, PATH_LENGTH); // check the file status if (isFileOk(filepath) == -1) { retcode = 5; write(fd, &retcode, sizeof (int)); close(accepted); return; } // opens the file if ((file = open(filepath, O_RDONLY)) == -1) { retcode = 5; write(fd, &retcode, sizeof (int)); close(accepted); return; } // read blocks of data from the file // and sends it through the data connection while ((r = read(file, buf, BUFSIZE)) > 0) { // ASCII type transfer if (cstate->transfer_type == ASCII) { char tmp[2 * BUFSIZE]; // converts \n to \r\n sequence, // return how much is the result longer if ((subn = im2as(tmp, buf, BUFSIZE)) == -1) { retcode = 5; write(fd, &retcode, sizeof (int)); close(accepted); break; } r += subn; memcpy(buf, tmp, BUFSIZE * 2); } if (write(accepted, buf, r) == -1) { retcode = 5; write(fd, &retcode, sizeof (int)); close(accepted); break; } } // closes the connection close(file); close(accepted); // reads and reports the result retcode = 2; write(fd, &retcode, sizeof (int)); }
void TraceDialog::browse() { QString fileName = QFileDialog::getOpenFileName( this, tr("Find the application"), QDir::currentPath()); if (!fileName.isEmpty() && isFileOk(fileName)) { applicationEdit->setText(fileName); } }
AglScene* ModelBaseFactory::readScene(const string& p_name, const string* p_path) { string fullPath; if (p_path!=NULL) fullPath = *p_path; fullPath += p_name; // test file string fileChkMsg; if (!isFileOk(fullPath,fileChkMsg,__FILE__,__FUNCTION__,__LINE__)) throw MeshLoadException(fileChkMsg); // read file and extract scene AglReader meshReader(fullPath.c_str()); AglScene* aglScene = meshReader.getScene(); return aglScene; }
void TraceDialog::accept() { if (isFileOk(applicationEdit->text())) { QDialog::accept(); } }