Package com.lpvs.util
Class LPVSFileUtil
java.lang.Object
com.lpvs.util.LPVSFileUtil
Utility class providing methods for handling files, directories, and file-related operations
in the context of LPVS application processing.
It includes functionality to save files, generate pretty patches, and manage local directory paths.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
deleteIfExists
(String path) Deletes the specified directory if it exists.static String
getLocalDirectoryPath
(LPVSQueue webhookConfig) Retrieves the local directory path based on the provided webhook configuration.static String
getPathByPullRequest
(LPVSQueue webhookConfig) Retrieves the local directory path for a given LPVSQueue configuration.static String
getScanResultsDirectoryPath
(LPVSQueue webhookConfig) Retrieves the directory path for storing scan results based on the provided webhook configuration.static String
getScanResultsJsonFilePath
(LPVSQueue webhookConfig) Retrieves the file path for storing scan results in JSON format based on the provided webhook configuration.static void
Saves a file with the specified content in a given directory.static String
saveGithubDiffs
(Iterable<org.kohsuke.github.GHPullRequestFileDetail> files, LPVSQueue webhookConfig) Saves the GitHub pull request file details, including the file patches, to a local directory.
-
Constructor Details
-
LPVSFileUtil
public LPVSFileUtil()
-
-
Method Details
-
saveFile
Saves a file with the specified content in a given directory.- Parameters:
fileName
- The name of the file to be saved.directoryPath
- The path to the directory where the file will be saved.patchedLines
- The content to be written to the file.
-
saveGithubDiffs
public static String saveGithubDiffs(Iterable<org.kohsuke.github.GHPullRequestFileDetail> files, LPVSQueue webhookConfig) Saves the GitHub pull request file details, including the file patches, to a local directory.- Parameters:
files
- The iterable of GitHub pull request file details.webhookConfig
- TheLPVSQueue
configuration for the webhook.- Returns:
- The path to the directory where the files are saved.
-
deleteIfExists
Deletes the specified directory if it exists.- Parameters:
path
- The path of the directory to be deleted.
-
getLocalDirectoryPath
Retrieves the local directory path based on the provided webhook configuration.- Parameters:
webhookConfig
- TheLPVSQueue
configuration for the webhook.- Returns:
- The local directory path.
-
getScanResultsJsonFilePath
Retrieves the file path for storing scan results in JSON format based on the provided webhook configuration.- Parameters:
webhookConfig
- TheLPVSQueue
configuration for the webhook.- Returns:
- The file path for storing scan results in JSON format.
-
getScanResultsDirectoryPath
Retrieves the directory path for storing scan results based on the provided webhook configuration.- Parameters:
webhookConfig
- TheLPVSQueue
configuration for the webhook.- Returns:
- The directory path for storing scan results.
-
getPathByPullRequest
Retrieves the local directory path for a given LPVSQueue configuration.- Parameters:
webhookConfig
- LPVSQueue configuration.- Returns:
- Local directory path for the given LPVSQueue.
-