From cf1c322756b102ba4165249eab037b01723796ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Thu, 8 May 2008 13:10:09 +0000 Subject: [PATCH] use find_directory() instead of /boot/home/ git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25373 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Window.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index d08fd8e975..40248795a8 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -19,10 +19,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -3248,15 +3250,23 @@ BWindow::_HandleKeyDown(BMessage* event) int32 rawKey; if (event->FindInt32("key", &rawKey) == B_OK && rawKey == B_PRINT_KEY) { // Get filename - char filename[128]; - BEntry entry; + BPath homePath; + if (find_directory(B_USER_DIRECTORY, &homePath) != B_OK) { + fprintf(stderr, "failed to find user home directory\n"); + return true; + } + + BPath path; + BEntry entry; int32 index = 1; do { - // TODO: Use find_directory(B_USER_DIRECTORY, ...) - sprintf(filename, "/boot/home/screen%ld.png", index++); - entry.SetTo(filename); - } while(entry.Exists()); + char filename[32]; + sprintf(filename, "screen%ld.png", index++); + path = homePath; + path.Append(filename); + entry.SetTo(path.Path()); + } while (entry.Exists()); // Get the screen bitmap BScreen screen(this); @@ -3264,7 +3274,7 @@ BWindow::_HandleKeyDown(BMessage* event) screen.GetBitmap(&screenDump, false); // Dump to PNG - SaveToPNG(filename, screen.Frame(), screenDump->ColorSpace(), + SaveToPNG(path.Path(), screen.Frame(), screenDump->ColorSpace(), screenDump->Bits(), screenDump->BitsLength(), screenDump->BytesPerRow());