コード例 #1
0
        std::string CreateIgniteHomeClasspath(const std::string& home, bool forceTest)
        {
            std::string res = std::string();

            // 1. Add exploded test directories.
            if (forceTest)
            {
                std::string examplesPath = home + "/examples";
                std::string examplesCp = ClasspathExploded(examplesPath, true);
                res.append(examplesCp);

                std::string modulesPath = home + "/modules";
                std::string modulesCp = ClasspathExploded(modulesPath, true);
                res.append(modulesCp);
            }

            // 2. Add regular jars from "libs" folder excluding "optional".
            std::string libsPath = home + "/libs";

            if (FileExists(libsPath))
            {
                res.append(ClasspathJars(libsPath));

                // Append inner directories.
                DIR* dir = opendir(libsPath.c_str());

                if (dir)
                {
                    struct dirent* entry;

                    while ((entry = readdir(dir)) != NULL)
                    {
                        std::string entryPath = entry->d_name;

                        if (entryPath.compare(".") != 0 && entryPath.compare("..") != 0 &&
                            entryPath.compare("optional") != 0)
                        {
                            std::string entryFullPath = libsPath;

                            entryFullPath.append("/");
                            entryFullPath.append(entryPath);

                            struct stat entryFullStat;

                            if (stat(entryFullPath.c_str(), &entryFullStat) != -1 && 
                                S_ISDIR(entryFullStat.st_mode)) 
                                res.append(ClasspathJars(entryFullPath));
                        }                                                              
                    }

                    closedir(dir);
                }
            }

            // 3. Return.
            return res;
        }
コード例 #2
0
ファイル: utils.cpp プロジェクト: Anackreon/ignite
            /**
             * Helper function to create classpath based on Ignite home directory.
             *
             * @param home Home directory; expected to be valid.
             * @param forceTest Force test classpath.
             */
            std::string CreateIgniteHomeClasspath(const std::string& home, bool forceTest)
            {
                std::string res = std::string();

                // 1. Add exploded test directories.
                if (forceTest)
                {
                    std::string examplesPath = home + "\\examples";
                    std::string examplesCp = ClasspathExploded(examplesPath, true);
                    res.append(examplesCp);

                    std::string modulesPath = home + "\\modules";
                    std::string modulesCp = ClasspathExploded(modulesPath, true);
                    res.append(modulesCp);
                }

                // 2. Add regular jars from "libs" folder excluding "optional".
                std::string libsPath = home + "\\libs";

                if (FileExists(libsPath))
                {
                    res.append(ClasspathJars(libsPath));

                    // Append inner directories.
                    std::string libsSearchPath = libsPath + "\\*";

                    WIN32_FIND_DATAA libsFindData;

                    HANDLE libsHnd = FindFirstFileA(libsSearchPath.c_str(), &libsFindData);

                    if (libsHnd != INVALID_HANDLE_VALUE)
                    {
                        do
                        {
                            if (libsFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
                            {
                                std::string libsChildPath = libsFindData.cFileName;

                                if (libsChildPath.compare(".") != 0 &&
                                    libsChildPath.compare("..") != 0 &&
                                    libsChildPath.compare("optional") != 0) {
                                    std::string libsFolder = libsPath + "\\" + libsChildPath;

                                    res.append(ClasspathJars(libsFolder));
                                }
                            }
                        } while (FindNextFileA(libsHnd, &libsFindData) != 0);

                        FindClose(libsHnd);
                    }
                }

                // 3. Return.
                return res;
            }
コード例 #3
0
ファイル: utils.cpp プロジェクト: Anackreon/ignite
            /**
             * Create classpath picking compiled classes from the given path.
             *
             * @path Path.
             * @return Classpath;
             */
            std::string ClasspathExploded(const std::string& path, bool down)
            {
                std::string res = std::string();

                if (FileExists(path))
                {
                    // 1. Append "target\classes".
                    std::string classesPath = path + "\\target\\classes";

                    if (FileExists(classesPath)) {
                        res.append(classesPath);
                        res.append(";");
                    }

                    // 2. Append "target\test-classes"
                    std::string testClassesPath = path + "\\target\\test-classes";

                    if (FileExists(testClassesPath)) {
                        res.append(testClassesPath);
                        res.append(";");
                    }

                    // 3. Append "target\libs"
                    std::string libsPath = path + "\\target\\libs";

                    if (FileExists(libsPath)) {
                        std::string libsCp = ClasspathJars(libsPath);
                        res.append(libsCp);
                    }

                    // 4. Do the same for child if needed.
                    if (down)
                    {
                        std::string searchPath = path + "\\*";

                        WIN32_FIND_DATAA findData;

                        HANDLE hnd = FindFirstFileA(searchPath.c_str(), &findData);

                        if (hnd != INVALID_HANDLE_VALUE)
                        {
                            do
                            {
                                if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
                                {
                                    std::string childPath = findData.cFileName;

                                    if (childPath.compare(".") != 0 &&
                                        childPath.compare("..") != 0)
                                    {
                                        std::string childCp =
                                            ClasspathExploded(path + "\\" + childPath, false);

                                        res.append(childCp);
                                    }
                                }
                            } while (FindNextFileA(hnd, &findData) != 0);

                            FindClose(hnd);
                        }
                    }
                }

                return res;
            }
コード例 #4
0
        /**
         * Create classpath picking compiled classes from the given path.
         *
         * @path Path.
         * @return Classpath;
         */
        std::string ClasspathExploded(const std::string& path, bool down)
        {
            std::string res;

            if (FileExists(path))
            {
                // 1. Append "target\classes".
                std::string classesPath = path + "/target/classes";

                if (FileExists(classesPath)) {
                    res += classesPath;
                    res += ":";
                }

                // 2. Append "target\test-classes"
                std::string testClassesPath = path + "/target/test-classes";

                if (FileExists(testClassesPath)) {
                    res += testClassesPath;
                    res += ":";
                }

                // 3. Append "target\libs"
                std::string libsPath = path + "/target/libs";

                if (FileExists(libsPath)) {
                    std::string libsCp = ClasspathJars(libsPath);
                    res += libsCp;
                }

                // 4. Do the same for child if needed.
                if (down)
                {
                    DIR* dir = opendir(path.c_str());

                    if (dir)
                    {
                        struct dirent* entry;

                        while ((entry = readdir(dir)) != NULL)
                        {
                            std::string entryPath = entry->d_name;

                            if (entryPath.compare(".") != 0 && entryPath.compare("..") != 0)
                            {
                                std::string entryFullPath = path + "/" + entryPath;

                                struct stat entryFullStat;

                                if (stat(entryFullPath.c_str(), &entryFullStat) != -1 && S_ISDIR(entryFullStat.st_mode))
                                {
                                    std::string childCp = ClasspathExploded(entryFullPath, false);

                                    res += childCp;
                                }
                            }
                        }

                        closedir(dir);
                    }
                }
            }

            return res;
        }