fspr_arch_file_io.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Licensed to the Apache Software Foundation (ASF) under one or more
  2. * contributor license agreements. See the NOTICE file distributed with
  3. * this work for additional information regarding copyright ownership.
  4. * The ASF licenses this file to You under the Apache License, Version 2.0
  5. * (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef FILE_IO_H
  17. #define FILE_IO_H
  18. #include "fspr_private.h"
  19. #include "fspr_general.h"
  20. #include "fspr_thread_mutex.h"
  21. #include "fspr_file_io.h"
  22. #include "fspr_file_info.h"
  23. #include "fspr_errno.h"
  24. #include "fspr_poll.h"
  25. /* We have an implementation of mkstemp but it's not very multi-threading
  26. * friendly & is part of the POSIX emulation rather than native so don't
  27. * use it.
  28. */
  29. #undef HAVE_MKSTEMP
  30. #define APR_FILE_BUFSIZE 4096
  31. struct fspr_file_t {
  32. fspr_pool_t *pool;
  33. HFILE filedes;
  34. char * fname;
  35. int isopen;
  36. int buffered;
  37. int eof_hit;
  38. fspr_int32_t flags;
  39. int timeout;
  40. int pipe;
  41. HEV pipeSem;
  42. enum { BLK_UNKNOWN, BLK_OFF, BLK_ON } blocking;
  43. /* Stuff for buffered mode */
  44. char *buffer;
  45. int bufpos; // Read/Write position in buffer
  46. unsigned long dataRead; // amount of valid data read into buffer
  47. int direction; // buffer being used for 0 = read, 1 = write
  48. unsigned long filePtr; // position in file of handle
  49. fspr_thread_mutex_t *mutex;// mutex semaphore, must be owned to access the above fields
  50. };
  51. struct fspr_dir_t {
  52. fspr_pool_t *pool;
  53. char *dirname;
  54. ULONG handle;
  55. FILEFINDBUF3 entry;
  56. int validentry;
  57. };
  58. fspr_status_t fspr_file_cleanup(void *);
  59. fspr_status_t fspr_os2_time_to_fspr_time(fspr_time_t *result, FDATE os2date,
  60. FTIME os2time);
  61. fspr_status_t fspr_fspr_time_to_os2_time(FDATE *os2date, FTIME *os2time,
  62. fspr_time_t aprtime);
  63. /* see win32/fileio.h for description of these */
  64. extern const char c_is_fnchar[256];
  65. #define IS_FNCHAR(c) c_is_fnchar[(unsigned char)c]
  66. fspr_status_t filepath_root_test(char *path, fspr_pool_t *p);
  67. fspr_status_t filepath_drive_get(char **rootpath, char drive,
  68. fspr_int32_t flags, fspr_pool_t *p);
  69. fspr_status_t filepath_root_case(char **rootpath, char *root, fspr_pool_t *p);
  70. #endif /* ! FILE_IO_H */