Lines Matching refs:file
145 _cpp_file *file; member
150 static bool open_file (_cpp_file *file);
151 static bool pch_open_file (cpp_reader *pfile, _cpp_file *file,
153 static bool find_file_in_dir (cpp_reader *pfile, _cpp_file *file,
155 static bool read_file_guts (cpp_reader *pfile, _cpp_file *file);
156 static bool read_file (cpp_reader *pfile, _cpp_file *file);
157 static bool should_stack_file (cpp_reader *, _cpp_file *file, bool import);
160 static const char *dir_name_of_file (_cpp_file *file);
161 static void open_file_failed (cpp_reader *pfile, _cpp_file *file, int);
174 static char *remap_filename (cpp_reader *pfile, _cpp_file *file);
176 static bool validate_pch (cpp_reader *, _cpp_file *file, const char *pchname);
201 open_file (_cpp_file *file) in open_file() argument
203 if (file->path[0] == '\0') in open_file()
205 file->fd = 0; in open_file()
209 file->fd = open (file->path, O_RDONLY | O_NOCTTY | O_BINARY, 0666); in open_file()
211 if (file->fd != -1) in open_file()
213 if (fstat (file->fd, &file->st) == 0) in open_file()
215 if (!S_ISDIR (file->st.st_mode)) in open_file()
217 file->err_no = 0; in open_file()
226 close (file->fd); in open_file()
227 file->fd = -1; in open_file()
232 file->err_no = errno; in open_file()
243 pch_open_file (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch) in pch_open_file() argument
246 const char *path = file->path; in pch_open_file()
253 if (file->name[0] == '\0' || !pfile->cb.valid_pch) in pch_open_file()
269 valid = validate_pch (pfile, file, pchname); in pch_open_file()
285 valid = validate_pch (pfile, file, pchname); in pch_open_file()
292 file->pch = true; in pch_open_file()
298 file->pchname = pchname; in pch_open_file()
311 find_file_in_dir (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch) in find_file_in_dir() argument
315 if (CPP_OPTION (pfile, remap) && (path = remap_filename (pfile, file))) in find_file_in_dir()
318 if (file->dir->construct) in find_file_in_dir()
319 path = file->dir->construct (file->name, file->dir); in find_file_in_dir()
321 path = append_file_to_dir (file->name, file->dir); in find_file_in_dir()
325 file->path = path; in find_file_in_dir()
326 if (pch_open_file (pfile, file, invalid_pch)) in find_file_in_dir()
329 if (open_file (file)) in find_file_in_dir()
332 if (file->err_no != ENOENT) in find_file_in_dir()
334 open_file_failed (pfile, file, 0); in find_file_in_dir()
339 file->path = file->name; in find_file_in_dir()
343 file->err_no = ENOENT; in find_file_in_dir()
344 file->path = NULL; in find_file_in_dir()
352 search_path_exhausted (cpp_reader *pfile, const char *header, _cpp_file *file) in search_path_exhausted() argument
359 && file->dir == NULL) in search_path_exhausted()
361 if ((file->path = func (pfile, header, &file->dir)) != NULL) in search_path_exhausted()
363 if (open_file (file)) in search_path_exhausted()
365 free ((void *)file->path); in search_path_exhausted()
367 file->path = file->name; in search_path_exhausted()
374 _cpp_find_failed (_cpp_file *file) in _cpp_find_failed() argument
376 return file->err_no != 0; in _cpp_find_failed()
397 _cpp_file *file; in _cpp_find_file() local
412 return entry->u.file; in _cpp_find_file()
414 file = make_cpp_file (pfile, start_dir, fname); in _cpp_find_file()
419 if (find_file_in_dir (pfile, file, &invalid_pch)) in _cpp_find_file()
422 file->dir = file->dir->next; in _cpp_find_file()
423 if (file->dir == NULL) in _cpp_find_file()
425 if (search_path_exhausted (pfile, fname, file)) in _cpp_find_file()
431 file->next_file = pfile->all_files; in _cpp_find_file()
432 pfile->all_files = file; in _cpp_find_file()
433 return file; in _cpp_find_file()
436 open_file_failed (pfile, file, angle_brackets); in _cpp_find_file()
451 if (file->dir != pfile->bracket_include in _cpp_find_file()
452 && file->dir != pfile->quote_include) in _cpp_find_file()
455 entry = search_cache (*hash_slot, file->dir); in _cpp_find_file()
463 free ((char *) file->name); in _cpp_find_file()
464 free (file); in _cpp_find_file()
465 file = entry->u.file; in _cpp_find_file()
470 file->next_file = pfile->all_files; in _cpp_find_file()
471 pfile->all_files = file; in _cpp_find_file()
478 entry->u.file = file; in _cpp_find_file()
481 return file; in _cpp_find_file()
493 read_file_guts (cpp_reader *pfile, _cpp_file *file) in read_file_guts() argument
499 if (S_ISBLK (file->st.st_mode)) in read_file_guts()
501 cpp_error (pfile, CPP_DL_ERROR, "%s is a block device", file->path); in read_file_guts()
505 regular = S_ISREG (file->st.st_mode); in read_file_guts()
516 if (file->st.st_size > INTTYPE_MAXIMUM (ssize_t)) in read_file_guts()
518 cpp_error (pfile, CPP_DL_ERROR, "%s is too large", file->path); in read_file_guts()
522 size = file->st.st_size; in read_file_guts()
532 while ((count = read (file->fd, buf + total, size - total)) > 0) in read_file_guts()
547 cpp_errno (pfile, CPP_DL_ERROR, file->path); in read_file_guts()
551 if (regular && total != size && STAT_SIZE_RELIABLE (file->st)) in read_file_guts()
553 "%s is shorter than expected", file->path); in read_file_guts()
555 file->buffer = _cpp_convert_input (pfile, CPP_OPTION (pfile, input_charset), in read_file_guts()
556 buf, size, total, &file->st.st_size); in read_file_guts()
557 file->buffer_valid = true; in read_file_guts()
566 read_file (cpp_reader *pfile, _cpp_file *file) in read_file() argument
569 if (file->buffer_valid) in read_file()
573 if (file->dont_read || file->err_no) in read_file()
576 if (file->fd == -1 && !open_file (file)) in read_file()
578 open_file_failed (pfile, file, 0); in read_file()
582 file->dont_read = !read_file_guts (pfile, file); in read_file()
583 close (file->fd); in read_file()
584 file->fd = -1; in read_file()
586 return !file->dont_read; in read_file()
592 should_stack_file (cpp_reader *pfile, _cpp_file *file, bool import) in should_stack_file() argument
597 if (file->once_only) in should_stack_file()
605 _cpp_mark_file_once_only (pfile, file); in should_stack_file()
608 if (file->stack_count) in should_stack_file()
614 if (file->cmacro && file->cmacro->type == NT_MACRO) in should_stack_file()
618 if (file->pch) in should_stack_file()
620 pfile->cb.read_pch (pfile, file->pchname, file->fd, file->path); in should_stack_file()
621 close (file->fd); in should_stack_file()
622 file->fd = -1; in should_stack_file()
626 if (!read_file (pfile, file)) in should_stack_file()
632 if (check_file_against_entries (pfile, file, import)) in should_stack_file()
638 _cpp_mark_file_once_only (pfile, file); in should_stack_file()
651 if (f == file) in should_stack_file()
656 && f->st.st_mtime == file->st.st_mtime in should_stack_file()
657 && f->st.st_size == file->st.st_size) in should_stack_file()
675 && ref_file->st.st_size == file->st.st_size in should_stack_file()
677 file->buffer, in should_stack_file()
678 file->st.st_size); in should_stack_file()
699 _cpp_stack_file (cpp_reader *pfile, _cpp_file *file, bool import) in _cpp_stack_file() argument
704 if (!should_stack_file (pfile, file, import)) in _cpp_stack_file()
707 if (pfile->buffer == NULL || file->dir == NULL) in _cpp_stack_file()
710 sysp = MAX (pfile->buffer->sysp, file->dir->sysp); in _cpp_stack_file()
713 if (CPP_OPTION (pfile, deps.style) > !!sysp && !file->stack_count) in _cpp_stack_file()
715 if (!file->main_file || !CPP_OPTION (pfile, deps.ignore_main_file)) in _cpp_stack_file()
716 deps_add_dep (pfile->deps, file->path); in _cpp_stack_file()
720 file->buffer_valid = false; in _cpp_stack_file()
721 file->stack_count++; in _cpp_stack_file()
724 buffer = cpp_push_buffer (pfile, file->buffer, file->st.st_size, in _cpp_stack_file()
726 buffer->file = file; in _cpp_stack_file()
734 _cpp_do_file_change (pfile, LC_ENTER, file->path, 1, sysp); in _cpp_stack_file()
741 _cpp_mark_file_once_only (cpp_reader *pfile, _cpp_file *file) in _cpp_mark_file_once_only() argument
744 file->once_only = true; in _cpp_mark_file_once_only()
755 _cpp_file *file; in search_path_head() local
761 file = pfile->buffer == NULL ? pfile->main_file : pfile->buffer->file; in search_path_head()
766 if (type == IT_INCLUDE_NEXT && file->dir) in search_path_head()
767 dir = file->dir->next; in search_path_head()
777 return make_cpp_dir (pfile, dir_name_of_file (file), in search_path_head()
791 dir_name_of_file (_cpp_file *file) in dir_name_of_file() argument
793 if (!file->dir_name) in dir_name_of_file()
795 size_t len = lbasename (file->path) - file->path; in dir_name_of_file()
798 memcpy (dir_name, file->path, len); in dir_name_of_file()
800 file->dir_name = dir_name; in dir_name_of_file()
803 return file->dir_name; in dir_name_of_file()
814 _cpp_file *file; in _cpp_stack_include() local
820 file = _cpp_find_file (pfile, fname, dir, false, angle_brackets); in _cpp_stack_include()
829 if (! file->pch && file->err_no == 0 && type != IT_CMDLINE) in _cpp_stack_include()
832 return _cpp_stack_file (pfile, file, type == IT_IMPORT); in _cpp_stack_include()
837 open_file_failed (cpp_reader *pfile, _cpp_file *file, int angle_brackets) in open_file_failed() argument
842 errno = file->err_no; in open_file_failed()
844 deps_add_dep (pfile->deps, file->name); in open_file_failed()
850 cpp_errno (pfile, CPP_DL_WARNING, file->path); in open_file_failed()
852 cpp_errno (pfile, CPP_DL_ERROR, file->path); in open_file_failed()
871 _cpp_file *file; in make_cpp_file() local
873 file = XCNEW (_cpp_file); in make_cpp_file()
874 file->main_file = !pfile->buffer; in make_cpp_file()
875 file->fd = -1; in make_cpp_file()
876 file->dir = dir; in make_cpp_file()
877 file->name = xstrdup (fname); in make_cpp_file()
879 return file; in make_cpp_file()
884 destroy_cpp_file (_cpp_file *file) in destroy_cpp_file() argument
886 if (file->buffer) in destroy_cpp_file()
887 free ((void *) file->buffer); in destroy_cpp_file()
888 free ((void *) file->name); in destroy_cpp_file()
889 free (file); in destroy_cpp_file()
963 while (entry && (entry->start_dir == NULL || entry->u.file->err_no)) in cpp_included()
977 hname = entry->u.file->name; in file_hash_hash()
993 hname = entry->u.file->name; in file_hash_eq()
1023 _cpp_find_file (pfile, fname, pfile->buffer->file->dir, true, 0); in _cpp_fake_include()
1064 _cpp_file *file = entry->u.file; in report_missing_guard() local
1067 if (file->cmacro == NULL && file->stack_count == 1 && !file->main_file) in report_missing_guard()
1076 fputs (entry->u.file->path, stderr); in report_missing_guard()
1101 _cpp_file *file; in _cpp_compare_file_date() local
1108 file = _cpp_find_file (pfile, fname, dir, false, angle_brackets); in _cpp_compare_file_date()
1109 if (file->err_no) in _cpp_compare_file_date()
1112 if (file->fd != -1) in _cpp_compare_file_date()
1114 close (file->fd); in _cpp_compare_file_date()
1115 file->fd = -1; in _cpp_compare_file_date()
1118 return file->st.st_mtime > pfile->buffer->file->st.st_mtime; in _cpp_compare_file_date()
1132 _cpp_pop_file_buffer (cpp_reader *pfile, _cpp_file *file) in _cpp_pop_file_buffer() argument
1136 if (pfile->mi_valid && file->cmacro == NULL) in _cpp_pop_file_buffer()
1137 file->cmacro = pfile->mi_cmacro; in _cpp_pop_file_buffer()
1142 if (file->buffer) in _cpp_pop_file_buffer()
1144 free ((void *) file->buffer); in _cpp_pop_file_buffer()
1145 file->buffer = NULL; in _cpp_pop_file_buffer()
1146 file->buffer_valid = false; in _cpp_pop_file_buffer()
1152 _cpp_get_file_stat (_cpp_file *file) in _cpp_get_file_stat() argument
1154 return &file->st; in _cpp_get_file_stat()
1294 remap_filename (cpp_reader *pfile, _cpp_file *file) in remap_filename() argument
1301 dir = file->dir; in remap_filename()
1302 fname = file->name; in remap_filename()
1330 validate_pch (cpp_reader *pfile, _cpp_file *file, const char *pchname) in validate_pch() argument
1332 const char *saved_path = file->path; in validate_pch()
1335 file->path = pchname; in validate_pch()
1336 if (open_file (file)) in validate_pch()
1338 valid = 1 & pfile->cb.valid_pch (pfile, pchname, file->fd); in validate_pch()
1342 close (file->fd); in validate_pch()
1343 file->fd = -1; in validate_pch()
1356 file->path = saved_path; in validate_pch()
1392 return b->file; in cpp_get_file()