Changeset 4e6a610 in mainline for uspace/lib/c/generic/stdio.c
- Timestamp:
- 2018-06-25T09:54:28Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bfe90b6
- Parents:
- fb0ec570
- git-author:
- Jiri Svoboda <jiri@…> (2018-06-24 17:51:54)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-06-25 09:54:28)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/stdio.c
rfb0ec570 r4e6a610 34 34 35 35 #include <errno.h> 36 #include <stdbool.h> 36 37 #include <stdio.h> 38 #include <str.h> 37 39 #include <str_error.h> 40 #include <tmpfile.h> 38 41 #include <vfs/vfs.h> 42 43 /** Static buffer for tmpnam function */ 44 static char tmpnam_buf[L_tmpnam]; 39 45 40 46 /** Get stream position. … … 82 88 rc = vfs_rename_path(old_path, new_path); 83 89 if (rc != EOK) { 90 /* 91 * Note that ISO C leaves the value of errno undefined, 92 * whereas according to UN*X standards, it is set. 93 */ 84 94 errno = rc; 85 95 return -1; … … 96 106 rc = vfs_unlink_path(path); 97 107 if (rc != EOK) { 108 /* 109 * Note that ISO C leaves the value of errno undefined, 110 * whereas according to UN*X standards, it is set. 111 */ 98 112 errno = rc; 99 113 return -1; … … 101 115 102 116 return 0; 117 } 118 119 /** Create a temporary file. 120 * 121 * @return Open stream descriptor or @c NULL on error. In that case 122 * errno is set (UN*X). Note that ISO C leaves the value of errno 123 * undefined. 124 */ 125 FILE *tmpfile(void) 126 { 127 int file; 128 FILE *stream; 129 130 file = __tmpfile(); 131 if (file < 0) { 132 printf("file is < 0\n"); 133 errno = EEXIST; 134 return NULL; 135 } 136 137 stream = fdopen(file, "w+"); 138 if (stream == NULL) { 139 printf("stream = NULL\n"); 140 vfs_put(file); 141 errno = EACCES; 142 return NULL; 143 } 144 145 printf("returning stream\n"); 146 return stream; 147 } 148 149 /** Create name for a temporary file. 150 * 151 * @param s Pointer to array of at least L_tmpnam bytes or @c NULL. 152 * @return The pointer @a s or pointer to internal static buffer on success, 153 * @c NULL on error. 154 */ 155 char *tmpnam(char *s) 156 { 157 char *p; 158 159 p = (s != NULL) ? s : tmpnam_buf; 160 return __tmpnam(p); 103 161 } 104 162 … … 115 173 } 116 174 175 117 176 /** @} 118 177 */
Note:
See TracChangeset
for help on using the changeset viewer.