MCPcopy Create free account
hub / github.com/OpenPrinting/cups / help_load_directory

Function help_load_directory

cgi-bin/help-index.c:734–830  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

732 */
733
734static int /* O - 0 = success, -1 = error, 1 = updated */
735help_load_directory(
736 help_index_t *hi, /* I - Index */
737 const char *directory, /* I - Directory */
738 const char *relative) /* I - Relative path */
739{
740 cups_dir_t *dir; /* Directory file */
741 cups_dentry_t *dent; /* Directory entry */
742 char *ext, /* Pointer to extension */
743 filename[1024], /* Full filename */
744 relname[1024]; /* Relative filename */
745 int update; /* Updated? */
746 help_node_t *node; /* Current node */
747
748
749 /*
750 * Open the directory and scan it...
751 */
752
753 if ((dir = cupsDirOpen(directory)) == NULL)
754 return (0);
755
756 update = 0;
757
758 while ((dent = cupsDirRead(dir)) != NULL)
759 {
760 /*
761 * Skip "." files...
762 */
763
764 if (dent->filename[0] == '.')
765 continue;
766
767 /*
768 * Get absolute and relative filenames...
769 */
770
771 snprintf(filename, sizeof(filename), "%s/%s", directory, dent->filename);
772 if (relative)
773 snprintf(relname, sizeof(relname), "%s/%s", relative, dent->filename);
774 else
775 strlcpy(relname, dent->filename, sizeof(relname));
776
777 /*
778 * Check if we have a HTML file...
779 */
780
781 if ((ext = strstr(dent->filename, ".html")) != NULL &&
782 (!ext[5] || !strcmp(ext + 5, ".gz")))
783 {
784 /*
785 * HTML file, see if we have already indexed the file...
786 */
787
788 if ((node = helpFindNode(hi, relname, NULL)) != NULL)
789 {
790 /*
791 * File already indexed - check dates to confirm that the

Callers 1

helpLoadIndexFunction · 0.85

Calls 6

cupsDirOpenFunction · 0.85
cupsDirReadFunction · 0.85
helpFindNodeFunction · 0.85
cupsArrayNextFunction · 0.85
help_load_fileFunction · 0.85
cupsDirCloseFunction · 0.85

Tested by

no test coverage detected