Add support for getting free space in Haiku.

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1474 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Adrien Destugues 2010-05-05 19:31:48 +00:00
parent aeec8451dc
commit 039c8a7194
4 changed files with 56 additions and 3 deletions

View File

@ -152,8 +152,9 @@ else
RMDIR = rmdir
CP = cp
BIN = ../bin/grafx2
PLATFORMOBJ = $(OBJDIR)/haiku.o
COPT = -W -Wall -c -g `sdl-config --cflags` $(TTFCOPT) -I/boot/common/include
LOPT = `sdl-config --libs` -lSDL_image -lpng -ljpeg -lz $(TTFLOPT) -lfreetype
LOPT = `sdl-config --libs` -lSDL_image -lpng -ljpeg -lz $(TTFLOPT) -lfreetype -lbe
CC = gcc
OBJDIR = ../obj/haiku
ZIP = zip
@ -387,6 +388,10 @@ depend :
$(OBJDIR)/winres.o : gfx2.ico
echo "1 ICON \"gfx2.ico\"" | $(WINDRES) -o $(OBJDIR)/winres.o
# Compile the C++ file needed in Haiku to use the API
$(OBJDIR)/haiku.o : haiku.cpp
g++ -c haiku.cpp -o $(OBJDIR)/haiku.o
clean :
$(DELCOMMAND) $(OBJ)
$(DELCOMMAND) $(BIN)

36
src/haiku.cpp Normal file
View File

@ -0,0 +1,36 @@
/* vim:expandtab:ts=2 sw=2:
*/
/* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2007 Adrien Destugues
Grafx2 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2
of the License.
Grafx2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/
#include "struct.h"
#ifdef __HAIKU__
#include <Entry.h>
#include <Volume.h>
extern "C" qword haiku_get_free_space(char* path);
qword haiku_get_free_space(char* path)
{
BEntry bpath(path);
entry_ref ref;
bpath.GetRef(&ref);
BVolume disk(ref.device);
return (qword) disk.Capacity();
}
#endif

8
src/haiku.h Normal file
View File

@ -0,0 +1,8 @@
#include "struct.h"
#ifndef __HAIKU_H
#define __HAIKU_H
qword haiku_get_free_space(char* path);
#endif

View File

@ -31,6 +31,8 @@
#include <sys/mount.h>
#elif defined (__linux__)
#include <sys/vfs.h>
#elif defined(__HAIKU__)
#include "haiku.h"
#endif
#include "const.h"
@ -62,7 +64,7 @@ word * Shortcut(word shortcut_number)
return &(Config_Key[shortcut_number & 0xFF][0]);
}
// Nom de la touche actuallement assignée à un raccourci d'après son numéro
// Nom de la touche actuallement assignée à un raccourci d'après son numéro
// de type 0x100+BOUTON_* ou SPECIAL_*
const char * Keyboard_shortcut_value(word shortcut_number)
{
@ -670,6 +672,8 @@ void Button_Stats(void)
statfs(Main_current_directory,&disk_info);
mem_size=(qword) disk_info.f_bfree * (qword) disk_info.f_bsize;
}
#elif defined(__HAIKU__)
mem_size = haiku_get_free_space(Main_current_directory);
#else
// Free disk space is only for shows. Other platforms can display 0.
#warning "Missing code for your platform !!! Check and correct please :)"