| 270 | /* Name may be 0 */ |
| 271 | |
| 272 | FILE *my_fdopen(File Filedes, const char *name, int Flags, myf MyFlags) |
| 273 | { |
| 274 | FILE *fd; |
| 275 | char type[5]; |
| 276 | DBUG_ENTER("my_fdopen"); |
| 277 | DBUG_PRINT("my",("Fd: %d Flags: %d MyFlags: %d", |
| 278 | Filedes, Flags, MyFlags)); |
| 279 | |
| 280 | make_ftype(type,Flags); |
| 281 | #ifdef _WIN32 |
| 282 | fd= my_win_fdopen(Filedes, type); |
| 283 | #else |
| 284 | fd= fdopen(Filedes, type); |
| 285 | #endif |
| 286 | if (!fd) |
| 287 | { |
| 288 | my_errno=errno; |
| 289 | if (MyFlags & (MY_FAE | MY_WME)) |
| 290 | { |
| 291 | char errbuf[MYSYS_STRERROR_SIZE]; |
| 292 | my_error(EE_CANT_OPEN_STREAM, MYF(ME_BELL+ME_WAITTANG), |
| 293 | my_errno, my_strerror(errbuf, sizeof(errbuf), my_errno)); |
| 294 | } |
| 295 | } |
| 296 | else |
| 297 | { |
| 298 | mysql_mutex_lock(&THR_LOCK_open); |
| 299 | my_stream_opened++; |
| 300 | if ((uint) Filedes < (uint) my_file_limit) |
| 301 | { |
| 302 | if (my_file_info[Filedes].type != UNOPEN) |
| 303 | { |
| 304 | my_file_opened--; /* File is opened with my_open ! */ |
| 305 | } |
| 306 | else |
| 307 | { |
| 308 | my_file_info[Filedes].name= my_strdup(name,MyFlags); |
| 309 | } |
| 310 | my_file_info[Filedes].type = STREAM_BY_FDOPEN; |
| 311 | } |
| 312 | mysql_mutex_unlock(&THR_LOCK_open); |
| 313 | } |
| 314 | |
| 315 | DBUG_PRINT("exit",("stream: 0x%lx", (long) fd)); |
| 316 | DBUG_RETURN(fd); |
| 317 | } /* my_fdopen */ |
| 318 | |
| 319 | |
| 320 | /* |
no test coverage detected