int ps4link_request_open(void *packet) { struct { unsigned int number; unsigned short length; int flags; char pathname[256]; } PACKED *request = packet; int result = -1; struct stat stats; // Fix the arguments. fix_pathname(request->pathname); if(request->pathname[0]==0) { return ps4link_response_open(-1); } request->flags = fix_flags(ntohl(request->flags)); debugNetPrintf(DEBUG,"Opening %s flags %x\n",request->pathname,request->flags); if(((stat(request->pathname, &stats) == 0) && (!S_ISDIR(stats.st_mode))) || (request->flags & O_CREAT)) { // Perform the request. #if defined (__CYGWIN__) || defined (__MINGW32__) result = open(request->pathname, request->flags | O_BINARY, 0644); #else result = open(request->pathname, request->flags, 0644); #endif } // Send the response. debugNetPrintf(DEBUG,"Open return %d\n",result); return ps4link_response_open(result); }
void PredictiveCursor::open(const Trie &trie, const String &str, UInt32 offset, UInt32 limit, UInt32 flags) { GRN_DAT_THROW_IF(PARAM_ERROR, (str.ptr() == NULL) && (str.length() != 0)); flags = fix_flags(flags); PredictiveCursor new_cursor(trie, offset, limit, flags); new_cursor.init(str); new_cursor.swap(this); }
void IdCursor::open(const Trie &trie, UInt32 min_id, UInt32 max_id, UInt32 offset, UInt32 limit, UInt32 flags) { flags = fix_flags(flags); IdCursor new_cursor(trie, offset, limit, flags); new_cursor.init(min_id, max_id); new_cursor.swap(this); }
void KeyCursor::open(const Trie &trie, const String &min_str, const String &max_str, UInt32 offset, UInt32 limit, UInt32 flags) { GRN_DAT_THROW_IF(PARAM_ERROR, (min_str.ptr() == NULL) && (min_str.length() != 0)); GRN_DAT_THROW_IF(PARAM_ERROR, (max_str.ptr() == NULL) && (max_str.length() != 0)); flags = fix_flags(flags); KeyCursor new_cursor(trie, offset, limit, flags); new_cursor.init(min_str, max_str); new_cursor.swap(this); }
bool replay_write(Replay *rpy, SDL_RWops *file, uint16_t version) { uint16_t base_version = (version & ~REPLAY_VERSION_COMPRESSION_BIT); bool compression = (version & REPLAY_VERSION_COMPRESSION_BIT); int i, j; SDL_RWwrite(file, replay_magic_header, sizeof(replay_magic_header), 1); SDL_WriteLE16(file, version); if(base_version >= REPLAY_STRUCT_VERSION_TS102000_REV0) { TaiseiVersion v; TAISEI_VERSION_GET_CURRENT(&v); if(taisei_version_write(file, &v) != TAISEI_VERSION_SIZE) { log_warn("Failed to write game version: %s", SDL_GetError()); return false; } } void *buf; SDL_RWops *abuf = NULL; SDL_RWops *vfile = file; if(compression) { abuf = SDL_RWAutoBuffer(&buf, 64); vfile = SDL_RWWrapZWriter(abuf, REPLAY_COMPRESSION_CHUNK_SIZE, false); } replay_write_string(vfile, config_get_str(CONFIG_PLAYERNAME), base_version); fix_flags(rpy); if(base_version >= REPLAY_STRUCT_VERSION_TS102000_REV1) { SDL_WriteLE32(vfile, rpy->flags); } SDL_WriteLE16(vfile, rpy->numstages); for(i = 0; i < rpy->numstages; ++i) { if(!replay_write_stage(rpy->stages + i, vfile, base_version)) { if(compression) { SDL_RWclose(vfile); SDL_RWclose(abuf); } return false; } } if(compression) { SDL_RWclose(vfile); SDL_WriteLE32(file, SDL_RWtell(file) + SDL_RWtell(abuf) + 4); SDL_RWwrite(file, buf, SDL_RWtell(abuf), 1); SDL_RWclose(abuf); vfile = SDL_RWWrapZWriter(file, REPLAY_COMPRESSION_CHUNK_SIZE, false); } for(i = 0; i < rpy->numstages; ++i) { ReplayStage *stg = rpy->stages + i; for(j = 0; j < stg->numevents; ++j) { if(!replay_write_stage_event(stg->events + j, vfile)) { if(compression) { SDL_RWclose(vfile); } return false; } } } if(compression) { SDL_RWclose(vfile); } // useless byte to simplify the premature EOF check, can be anything SDL_WriteU8(file, REPLAY_USELESS_BYTE); return true; }