Lines Matching refs:file
147 _cpp_file *file; member
152 static bool open_file (_cpp_file *file);
153 static bool pch_open_file (cpp_reader *pfile, _cpp_file *file,
155 static bool find_file_in_dir (cpp_reader *pfile, _cpp_file *file,
157 static bool read_file_guts (cpp_reader *pfile, _cpp_file *file);
158 static bool read_file (cpp_reader *pfile, _cpp_file *file);
159 static bool should_stack_file (cpp_reader *, _cpp_file *file, bool import);
162 static const char *dir_name_of_file (_cpp_file *file);
163 static void open_file_failed (cpp_reader *pfile, _cpp_file *file, int);
176 static char *remap_filename (cpp_reader *pfile, _cpp_file *file);
178 static bool validate_pch (cpp_reader *, _cpp_file *file, const char *pchname);
203 open_file (_cpp_file *file) in open_file() argument
205 if (file->path[0] == '\0') in open_file()
207 file->fd = 0; in open_file()
211 file->fd = open (file->path, O_RDONLY | O_NOCTTY | O_BINARY, 0666); in open_file()
213 if (file->fd != -1) in open_file()
215 if (fstat (file->fd, &file->st) == 0) in open_file()
217 if (!S_ISDIR (file->st.st_mode)) in open_file()
219 file->err_no = 0; in open_file()
228 close (file->fd); in open_file()
229 file->fd = -1; in open_file()
234 file->err_no = errno; in open_file()
245 pch_open_file (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch) in pch_open_file() argument
248 const char *path = file->path; in pch_open_file()
255 if (file->name[0] == '\0' || !pfile->cb.valid_pch) in pch_open_file()
271 valid = validate_pch (pfile, file, pchname); in pch_open_file()
287 valid = validate_pch (pfile, file, pchname); in pch_open_file()
294 file->pch = true; in pch_open_file()
300 file->pchname = pchname; in pch_open_file()
313 find_file_in_dir (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch) in find_file_in_dir() argument
317 if (CPP_OPTION (pfile, remap) && (path = remap_filename (pfile, file))) in find_file_in_dir()
320 if (file->dir->construct) in find_file_in_dir()
321 path = file->dir->construct (file->name, file->dir); in find_file_in_dir()
323 path = append_file_to_dir (file->name, file->dir); in find_file_in_dir()
333 file->err_no = ENOENT; in find_file_in_dir()
337 file->path = path; in find_file_in_dir()
338 if (pch_open_file (pfile, file, invalid_pch)) in find_file_in_dir()
341 if (open_file (file)) in find_file_in_dir()
344 if (file->err_no != ENOENT) in find_file_in_dir()
346 open_file_failed (pfile, file, 0); in find_file_in_dir()
360 file->path = file->name; in find_file_in_dir()
364 file->err_no = ENOENT; in find_file_in_dir()
365 file->path = NULL; in find_file_in_dir()
373 search_path_exhausted (cpp_reader *pfile, const char *header, _cpp_file *file) in search_path_exhausted() argument
380 && file->dir == NULL) in search_path_exhausted()
382 if ((file->path = func (pfile, header, &file->dir)) != NULL) in search_path_exhausted()
384 if (open_file (file)) in search_path_exhausted()
386 free ((void *)file->path); in search_path_exhausted()
388 file->path = file->name; in search_path_exhausted()
395 _cpp_find_failed (_cpp_file *file) in _cpp_find_failed() argument
397 return file->err_no != 0; in _cpp_find_failed()
418 _cpp_file *file; in _cpp_find_file() local
436 return entry->u.file; in _cpp_find_file()
438 file = make_cpp_file (pfile, start_dir, fname); in _cpp_find_file()
443 if (find_file_in_dir (pfile, file, &invalid_pch)) in _cpp_find_file()
446 file->dir = file->dir->next; in _cpp_find_file()
447 if (file->dir == NULL) in _cpp_find_file()
449 if (search_path_exhausted (pfile, fname, file)) in _cpp_find_file()
455 file->next_file = pfile->all_files; in _cpp_find_file()
456 pfile->all_files = file; in _cpp_find_file()
457 return file; in _cpp_find_file()
460 open_file_failed (pfile, file, angle_brackets); in _cpp_find_file()
475 if (file->dir == pfile->bracket_include) in _cpp_find_file()
477 else if (file->dir == pfile->quote_include) in _cpp_find_file()
482 entry = search_cache (*hash_slot, file->dir); in _cpp_find_file()
485 found_in_cache = file->dir; in _cpp_find_file()
493 free ((char *) file->name); in _cpp_find_file()
494 free (file); in _cpp_find_file()
495 file = entry->u.file; in _cpp_find_file()
500 file->next_file = pfile->all_files; in _cpp_find_file()
501 pfile->all_files = file; in _cpp_find_file()
508 entry->u.file = file; in _cpp_find_file()
520 entry->u.file = file; in _cpp_find_file()
530 entry->u.file = file; in _cpp_find_file()
534 return file; in _cpp_find_file()
546 read_file_guts (cpp_reader *pfile, _cpp_file *file) in read_file_guts() argument
553 if (S_ISBLK (file->st.st_mode)) in read_file_guts()
555 cpp_error (pfile, CPP_DL_ERROR, "%s is a block device", file->path); in read_file_guts()
559 regular = S_ISREG (file->st.st_mode); in read_file_guts()
570 if (file->st.st_size > SSIZE_MAX) in read_file_guts()
572 cpp_error (pfile, CPP_DL_ERROR, "%s is too large", file->path); in read_file_guts()
576 size = file->st.st_size; in read_file_guts()
578 if ((offset = lseek(file->fd, 0, SEEK_CUR)) < 0) in read_file_guts()
581 file->path); in read_file_guts()
587 file->path); in read_file_guts()
601 while ((count = read (file->fd, buf + total, size - total)) > 0) in read_file_guts()
616 cpp_errno (pfile, CPP_DL_ERROR, file->path); in read_file_guts()
620 if (regular && total != size && STAT_SIZE_RELIABLE (file->st)) in read_file_guts()
622 "%s is shorter than expected", file->path); in read_file_guts()
624 file->buffer = _cpp_convert_input (pfile, CPP_OPTION (pfile, input_charset), in read_file_guts()
625 buf, size, total, &file->st.st_size); in read_file_guts()
626 file->buffer_valid = true; in read_file_guts()
635 read_file (cpp_reader *pfile, _cpp_file *file) in read_file() argument
638 if (file->buffer_valid) in read_file()
642 if (file->dont_read || file->err_no) in read_file()
645 if (file->fd == -1 && !open_file (file)) in read_file()
647 open_file_failed (pfile, file, 0); in read_file()
651 file->dont_read = !read_file_guts (pfile, file); in read_file()
652 close (file->fd); in read_file()
653 file->fd = -1; in read_file()
655 return !file->dont_read; in read_file()
661 should_stack_file (cpp_reader *pfile, _cpp_file *file, bool import) in should_stack_file() argument
666 if (file->once_only) in should_stack_file()
674 _cpp_mark_file_once_only (pfile, file); in should_stack_file()
677 if (file->stack_count) in should_stack_file()
683 if (file->cmacro && file->cmacro->type == NT_MACRO) in should_stack_file()
687 if (file->pch) in should_stack_file()
689 pfile->cb.read_pch (pfile, file->pchname, file->fd, file->path); in should_stack_file()
690 close (file->fd); in should_stack_file()
691 file->fd = -1; in should_stack_file()
695 if (!read_file (pfile, file)) in should_stack_file()
701 if (check_file_against_entries (pfile, file, import)) in should_stack_file()
707 _cpp_mark_file_once_only (pfile, file); in should_stack_file()
720 if (f == file) in should_stack_file()
725 && f->st.st_mtime == file->st.st_mtime in should_stack_file()
726 && f->st.st_size == file->st.st_size) in should_stack_file()
744 && ref_file->st.st_size == file->st.st_size in should_stack_file()
746 file->buffer, in should_stack_file()
747 file->st.st_size); in should_stack_file()
768 _cpp_stack_file (cpp_reader *pfile, _cpp_file *file, bool import) in _cpp_stack_file() argument
773 if (!should_stack_file (pfile, file, import)) in _cpp_stack_file()
776 if (pfile->buffer == NULL || file->dir == NULL) in _cpp_stack_file()
779 sysp = MAX (pfile->buffer->sysp, file->dir->sysp); in _cpp_stack_file()
782 if (CPP_OPTION (pfile, deps.style) > !!sysp && !file->stack_count) in _cpp_stack_file()
784 if (!file->main_file || !CPP_OPTION (pfile, deps.ignore_main_file)) in _cpp_stack_file()
785 deps_add_dep (pfile->deps, file->path); in _cpp_stack_file()
789 file->buffer_valid = false; in _cpp_stack_file()
790 file->stack_count++; in _cpp_stack_file()
793 buffer = cpp_push_buffer (pfile, file->buffer, file->st.st_size, in _cpp_stack_file()
796 buffer->file = file; in _cpp_stack_file()
804 _cpp_do_file_change (pfile, LC_ENTER, file->path, 1, sysp); in _cpp_stack_file()
811 _cpp_mark_file_once_only (cpp_reader *pfile, _cpp_file *file) in _cpp_mark_file_once_only() argument
814 file->once_only = true; in _cpp_mark_file_once_only()
825 _cpp_file *file; in search_path_head() local
831 file = pfile->buffer == NULL ? pfile->main_file : pfile->buffer->file; in search_path_head()
836 if (type == IT_INCLUDE_NEXT && file->dir) in search_path_head()
837 dir = file->dir->next; in search_path_head()
847 return make_cpp_dir (pfile, dir_name_of_file (file), in search_path_head()
861 dir_name_of_file (_cpp_file *file) in dir_name_of_file() argument
863 if (!file->dir_name) in dir_name_of_file()
865 size_t len = lbasename (file->path) - file->path; in dir_name_of_file()
868 memcpy (dir_name, file->path, len); in dir_name_of_file()
870 file->dir_name = dir_name; in dir_name_of_file()
873 return file->dir_name; in dir_name_of_file()
884 _cpp_file *file; in _cpp_stack_include() local
890 file = _cpp_find_file (pfile, fname, dir, false, angle_brackets); in _cpp_stack_include()
899 if (! file->pch && file->err_no == 0 && type != IT_CMDLINE) in _cpp_stack_include()
902 return _cpp_stack_file (pfile, file, type == IT_IMPORT); in _cpp_stack_include()
907 open_file_failed (cpp_reader *pfile, _cpp_file *file, int angle_brackets) in open_file_failed() argument
912 errno = file->err_no; in open_file_failed()
914 deps_add_dep (pfile->deps, file->name); in open_file_failed()
920 cpp_errno (pfile, CPP_DL_WARNING, file->path); in open_file_failed()
922 cpp_errno (pfile, CPP_DL_ERROR, file->path); in open_file_failed()
941 _cpp_file *file; in make_cpp_file() local
943 file = XCNEW (_cpp_file); in make_cpp_file()
944 file->main_file = !pfile->buffer; in make_cpp_file()
945 file->fd = -1; in make_cpp_file()
946 file->dir = dir; in make_cpp_file()
947 file->name = xstrdup (fname); in make_cpp_file()
949 return file; in make_cpp_file()
954 destroy_cpp_file (_cpp_file *file) in destroy_cpp_file() argument
956 if (file->buffer) in destroy_cpp_file()
957 free ((void *) file->buffer); in destroy_cpp_file()
958 free ((void *) file->name); in destroy_cpp_file()
959 free (file); in destroy_cpp_file()
1033 while (entry && (entry->start_dir == NULL || entry->u.file->err_no)) in cpp_included()
1047 hname = entry->u.file->name; in file_hash_hash()
1063 hname = entry->u.file->name; in file_hash_eq()
1109 _cpp_find_file (pfile, fname, pfile->buffer->file->dir, true, 0); in _cpp_fake_include()
1150 _cpp_file *file = entry->u.file; in report_missing_guard() local
1153 if (file->cmacro == NULL && file->stack_count == 1 && !file->main_file) in report_missing_guard()
1162 fputs (entry->u.file->path, stderr); in report_missing_guard()
1187 _cpp_file *file; in _cpp_compare_file_date() local
1194 file = _cpp_find_file (pfile, fname, dir, false, angle_brackets); in _cpp_compare_file_date()
1195 if (file->err_no) in _cpp_compare_file_date()
1198 if (file->fd != -1) in _cpp_compare_file_date()
1200 close (file->fd); in _cpp_compare_file_date()
1201 file->fd = -1; in _cpp_compare_file_date()
1204 return file->st.st_mtime > pfile->buffer->file->st.st_mtime; in _cpp_compare_file_date()
1218 _cpp_pop_file_buffer (cpp_reader *pfile, _cpp_file *file) in _cpp_pop_file_buffer() argument
1222 if (pfile->mi_valid && file->cmacro == NULL) in _cpp_pop_file_buffer()
1223 file->cmacro = pfile->mi_cmacro; in _cpp_pop_file_buffer()
1228 if (file->buffer) in _cpp_pop_file_buffer()
1230 free ((void *) file->buffer); in _cpp_pop_file_buffer()
1231 file->buffer = NULL; in _cpp_pop_file_buffer()
1232 file->buffer_valid = false; in _cpp_pop_file_buffer()
1238 _cpp_get_file_stat (_cpp_file *file) in _cpp_get_file_stat() argument
1240 return &file->st; in _cpp_get_file_stat()
1380 remap_filename (cpp_reader *pfile, _cpp_file *file) in remap_filename() argument
1387 dir = file->dir; in remap_filename()
1388 fname = file->name; in remap_filename()
1416 validate_pch (cpp_reader *pfile, _cpp_file *file, const char *pchname) in validate_pch() argument
1418 const char *saved_path = file->path; in validate_pch()
1421 file->path = pchname; in validate_pch()
1422 if (open_file (file)) in validate_pch()
1424 valid = 1 & pfile->cb.valid_pch (pfile, pchname, file->fd); in validate_pch()
1428 close (file->fd); in validate_pch()
1429 file->fd = -1; in validate_pch()
1442 file->path = saved_path; in validate_pch()
1478 return b->file; in cpp_get_file()