1
0
mirror of https://github.com/JustKato/FreePad.git synced 2026-02-23 15:50:46 +02:00

* Previous commit

This commit is contained in:
2022-06-03 22:56:25 +03:00
parent c3c9aacac3
commit b710d24a2d
3 changed files with 148 additions and 0 deletions

View File

@@ -295,3 +295,30 @@ func CleanupPosts(age int) {
}
}
func GetAllPosts() []Post {
// Initialize the list of posts
postList := []Post{}
// Get the posts storage directory
storageDir := getStorageDirectory()
// Read the directory listing
files, err := os.ReadDir(storageDir)
// Check if thereh as been an issues with reading the directory contents
if err != nil {
// Log the error
fmt.Println("Error::GetAllPosts:", err)
// Return an empty list to have a clean fallback
return []Post{}
}
// Go through all of the files
for _, v := range files {
// Process the file into a pad
postList = append(postList, GetPost(v.Name()))
}
// Return the post list
return postList
}