* Fixed bug in "fortune" that would let it crash if you'd point it to an empty
directory. * Moved fortune files to "data/system/data" in the repository, and /system/data/ in the file system. * Got teapot.data location wrong in the repository. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33982 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -403,16 +403,13 @@ AddFilesToHaikuImage system etc vim : <etc>vimrc ;
|
||||
|
||||
local dataFiles = teapot.data ;
|
||||
dataFiles = $(dataFiles:G=data) ;
|
||||
SEARCH on $(dataFiles) = [ FDirName $(HAIKU_TOP) data ] ;
|
||||
SEARCH on $(dataFiles) = [ FDirName $(HAIKU_TOP) data system data ] ;
|
||||
AddFilesToHaikuImage system data : $(dataFiles) ;
|
||||
|
||||
local fortuneFiles = Art Computers Education Food Fortunes Goedel Haiku
|
||||
Humorists Kids Law "Linux cookies" Love Magic Medicine Miscellaneous
|
||||
News "One Liners" "OS Fortunes" Pets Platitudes Riddles "Songs & Poems"
|
||||
Sports "Tech Support Excuses" ;
|
||||
fortuneFiles = $(fortuneFiles:G=etc!fortunes) ;
|
||||
SEARCH on $(fortuneFiles) = [ FDirName $(HAIKU_TOP) data etc fortunes ] ;
|
||||
AddFilesToHaikuImage system etc fortunes : $(fortuneFiles) ;
|
||||
local fortuneFiles = [ Glob $(HAIKU_TOP)/data/system/data/fortunes
|
||||
: [a-zA-Z0-9]* ] ;
|
||||
fortuneFiles = $(fortuneFiles:G=data!fortunes) ;
|
||||
AddFilesToHaikuImage system data fortunes : $(fortuneFiles) ;
|
||||
|
||||
local fontDir = [ FDirName $(HAIKU_TOP) data system data fonts ] ;
|
||||
local psFonts = [ Glob $(fontDir)/psfonts : *.afm *.pfb ] ;
|
||||
|
||||
+10
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008, Haiku. All rights reserved.
|
||||
* Copyright 2002-2009, Haiku. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@@ -13,12 +13,10 @@
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <FindDirectory.h>
|
||||
#include <OS.h>
|
||||
|
||||
|
||||
#define FORTUNES "/etc/fortunes"
|
||||
|
||||
|
||||
static int
|
||||
choose_file(const char *path)
|
||||
{
|
||||
@@ -39,6 +37,9 @@ choose_file(const char *path)
|
||||
count++;
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
return -1;
|
||||
|
||||
// choose and open entry
|
||||
|
||||
chosen = rand() % count;
|
||||
@@ -75,7 +76,8 @@ choose_file(const char *path)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char *file = FORTUNES;
|
||||
char path[PATH_MAX] = {'\0'};
|
||||
const char *file = path;
|
||||
int fd;
|
||||
char *buffer;
|
||||
unsigned start, i;
|
||||
@@ -87,6 +89,9 @@ main(int argc, char **argv)
|
||||
if (argc > 1) {
|
||||
// if there are arguments, choose one randomly
|
||||
file = argv[1 + (rand() % (argc - 1))];
|
||||
} else if (find_directory(B_SYSTEM_DATA_DIRECTORY, -1, false, path,
|
||||
sizeof(path)) == B_OK) {
|
||||
strlcat(path, "/fortunes", sizeof(path));
|
||||
}
|
||||
|
||||
fd = open(file, O_RDONLY, 0);
|
||||
|
||||
Reference in New Issue
Block a user