---------------------------------------------------------------------* * Boxaa serialized I/O * *---------------------------------------------------------------------*/ ! * \brief boxaaReadFromFiles() * * \param[in] dirname directory * \param[in] substr [optional] substring filter on filenames; can be NULL * \param[in] first 0-based
| 1821 | * </pre> |
| 1822 | */ |
| 1823 | BOXAA * |
| 1824 | boxaaReadFromFiles(const char *dirname, |
| 1825 | const char *substr, |
| 1826 | l_int32 first, |
| 1827 | l_int32 nfiles) |
| 1828 | { |
| 1829 | char *fname; |
| 1830 | l_int32 i, n; |
| 1831 | BOXA *boxa; |
| 1832 | BOXAA *baa; |
| 1833 | SARRAY *sa; |
| 1834 | |
| 1835 | PROCNAME("boxaaReadFromFiles"); |
| 1836 | |
| 1837 | if (!dirname) |
| 1838 | return (BOXAA *)ERROR_PTR("dirname not defined", procName, NULL); |
| 1839 | |
| 1840 | sa = getSortedPathnamesInDirectory(dirname, substr, first, nfiles); |
| 1841 | if (!sa || ((n = sarrayGetCount(sa)) == 0)) { |
| 1842 | sarrayDestroy(&sa); |
| 1843 | return (BOXAA *)ERROR_PTR("no pixa files found", procName, NULL); |
| 1844 | } |
| 1845 | |
| 1846 | baa = boxaaCreate(n); |
| 1847 | for (i = 0; i < n; i++) { |
| 1848 | fname = sarrayGetString(sa, i, L_NOCOPY); |
| 1849 | if ((boxa = boxaRead(fname)) == NULL) { |
| 1850 | L_ERROR("boxa not read for %d-th file", procName, i); |
| 1851 | continue; |
| 1852 | } |
| 1853 | boxaaAddBoxa(baa, boxa, L_INSERT); |
| 1854 | } |
| 1855 | |
| 1856 | sarrayDestroy(&sa); |
| 1857 | return baa; |
| 1858 | } |
| 1859 | |
| 1860 | |
| 1861 | /*! |
nothing calls this directly
no test coverage detected