Fixed ordering of OK/Cancel buttons for OSX vs. Linux/Windows.

Added better sanity checks to file browser dialog through FSNode.  It now
checks if a user-specified directory name is correct, and if not, it uses
a valid default. Still TODO is add similar checks to the Win32 FSNode.

Totally finished the LauncherOptionsDialog.  You can now change Snapshot
settings there as well.

Fixed potential memory leak in PopUpWidget.  It was needlessly creating
and destroying PopUpDialog objects, and under certain circumstances the
objects were never deleted.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@424 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-05-14 03:26:29 +00:00
parent 8bed0dfc75
commit addac558c1
9 changed files with 139 additions and 204 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Settings.cxx,v 1.42 2005-05-13 18:28:05 stephena Exp $
// $Id: Settings.cxx,v 1.43 2005-05-14 03:26:28 stephena Exp $
//============================================================================
#include <cassert>
@ -61,7 +61,7 @@ Settings::Settings(OSystem* osystem)
set("showinfo", "false");
set("mergeprops", "false");
set("ssdir", ".");
set("ssdir", "");
set("ssname", "romname");
set("sssingle", "false");

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: BrowserDialog.cxx,v 1.3 2005-05-13 18:28:05 stephena Exp $
// $Id: BrowserDialog.cxx,v 1.4 2005-05-14 03:26:29 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -61,8 +61,13 @@ BrowserDialog::BrowserDialog(GuiObject* boss, int x, int y, int w, int h)
// Buttons
addButton(10, _h - 24, "Go up", kGoUpCmd, 0);
#ifndef MAC_OSX
addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "Choose", kChooseCmd, 0);
addButton(_w - (kButtonWidth+10), _h - 24, "Cancel", kCloseCmd, 0);
#else
addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
addButton(_w - (kButtonWidth+10), _h - 24, "Choose", kChooseCmd, 0);
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -70,7 +75,6 @@ void BrowserDialog::setStartPath(const string& startpath)
{
// If no node has been set, or the last used one is now invalid,
// go back to the root/default dir.
if (startpath != "")
_choice = FilesystemNode(startpath);
if (_choice.isValid())

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: GuiObject.hxx,v 1.7 2005-05-13 18:28:05 stephena Exp $
// $Id: GuiObject.hxx,v 1.8 2005-05-14 03:26:29 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -33,7 +33,7 @@ class Widget;
This is the base class for all GUI objects/widgets.
@author Stephen Anthony
@version $Id: GuiObject.hxx,v 1.7 2005-05-13 18:28:05 stephena Exp $
@version $Id: GuiObject.hxx,v 1.8 2005-05-14 03:26:29 stephena Exp $
*/
class GuiObject : public CommandReceiver
{
@ -60,6 +60,9 @@ class GuiObject : public CommandReceiver
virtual int getWidth() const { return _w; }
virtual int getHeight() const { return _h; }
virtual void setWidth(int w) { _w = w; }
virtual void setHeight(int h) { _h = h; }
virtual bool isVisible() const = 0;
virtual void draw() = 0;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: LauncherDialog.cxx,v 1.12 2005-05-13 18:28:05 stephena Exp $
// $Id: LauncherDialog.cxx,v 1.13 2005-05-14 03:26:29 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -43,15 +43,7 @@ enum {
kStartCmd = 'STRT',
kOptionsCmd = 'OPTI',
kReloadCmd = 'RELO',
kQuitCmd = 'QUIT',
kCmdGlobalGraphicsOverride = 'OGFX',
kCmdGlobalAudioOverride = 'OSFX',
kCmdGlobalVolumeOverride = 'OVOL',
kCmdExtraBrowser = 'PEXT',
kCmdGameBrowser = 'PGME',
kCmdSaveBrowser = 'PSAV'
kQuitCmd = 'QUIT'
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -75,6 +67,7 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
const int width = (_w - 2 * border - space * (buttons - 1)) / buttons;
int xpos = border;
#ifndef MAC_OSX
new ButtonWidget(this, xpos, _h - 24, width, 16, "Play", kStartCmd, 'S');
xpos += space + width;
new ButtonWidget(this, xpos, _h - 24, width, 16, "Options", kOptionsCmd, 'O');
@ -83,6 +76,16 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
xpos += space + width;
new ButtonWidget(this, xpos, _h - 24, width, 16, "Quit", kQuitCmd, 'Q');
xpos += space + width;
#else
new ButtonWidget(this, xpos, _h - 24, width, 16, "Quit", kQuitCmd, 'Q');
xpos += space + width;
new ButtonWidget(this, xpos, _h - 24, width, 16, "Options", kOptionsCmd, 'O');
xpos += space + width;
new ButtonWidget(this, xpos, _h - 24, width, 16, "Reload", kReloadCmd, 'R');
xpos += space + width;
new ButtonWidget(this, xpos, _h - 24, width, 16, "Start", kStartCmd, 'Q');
xpos += space + width;
#endif
// Add list with game titles
myList = new ListWidget(this, 10, 24, _w - 20, _h - 24 - 26 - 10 - 10);
@ -114,7 +117,7 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
// Create the launcher options dialog, where you can change ROM
// and snapshot paths
myOptions = new LauncherOptionsDialog(osystem, parent, 20, 40, _w - 40, _h - 80);
myOptions = new LauncherOptionsDialog(osystem, parent, 20, 60, _w - 40, _h - 120);
// Create a game list, which contains all the information about a ROM that
// the launcher needs
@ -208,7 +211,7 @@ void LauncherDialog::loadListFromDisk()
// Create a entry for the GameList for each file
string path = dir.path(), rom, md5, name, note;
for (int idx = 0; idx < (int)files.size(); idx++)
for (unsigned int idx = 0; idx < files.size(); idx++)
{
rom = path + files[idx].displayName();
@ -300,7 +303,7 @@ string LauncherDialog::MD5FromFile(const string& path)
uInt8* image = new uInt8[512 * 1024];
in.read((char*)image, 512 * 1024);
int size = in.gcount();
int size = (int) in.gcount();
in.close();
string md5 = MD5(image, size);

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: LauncherOptionsDialog.cxx,v 1.2 2005-05-13 18:28:05 stephena Exp $
// $Id: LauncherOptionsDialog.cxx,v 1.3 2005-05-14 03:26:29 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -52,30 +52,49 @@ LauncherOptionsDialog::LauncherOptionsDialog(
yoffset = vBorder;
// ROM path
new ButtonWidget(tab, 5, yoffset, kButtonWidth + 14, 16, "Path", kChooseRomDirCmd, 0);
myRomPath = new StaticTextWidget(tab, 5 + kButtonWidth + 20, yoffset + 3, _w - (5 + kButtonWidth + 20) - 10, kLineHeight, "xxx", kTextAlignLeft);
new ButtonWidget(tab, 15, yoffset, kButtonWidth + 14, 16, "Path", kChooseRomDirCmd, 0);
myRomPath = new StaticTextWidget(tab, 5 + kButtonWidth + 30,
yoffset + 3, _w - (5 + kButtonWidth + 20) - 10,
kLineHeight, "", kTextAlignLeft);
// 2) The snapshot settings tab
tab->addTab(" Snapshot Settings ");
yoffset = vBorder;
// Save game path
new ButtonWidget(tab, 5, yoffset, kButtonWidth + 14, 16, "Path", kChooseSnapDirCmd, 0);
mySnapPath = new StaticTextWidget(tab, 5 + kButtonWidth + 20, yoffset + 3, _w - (5 + kButtonWidth + 20) - 10, kLineHeight, "yyy", kTextAlignLeft);
// Snapshot path
new ButtonWidget(tab, 15, yoffset, kButtonWidth + 14, 16, "Path", kChooseSnapDirCmd, 0);
mySnapPath = new StaticTextWidget(tab, 5 + kButtonWidth + 30,
yoffset + 3, _w - (5 + kButtonWidth + 20) - 10,
kLineHeight, "", kTextAlignLeft);
yoffset += 22;
// Snapshot save name
mySnapTypePopup = new PopUpWidget(tab, 10, yoffset, 140, kLineHeight,
"Save snapshot as: ", 87, 0);
mySnapTypePopup->appendEntry("romname", 1);
mySnapTypePopup->appendEntry("md5sum", 2);
yoffset += 18;
// FIXME - add other snapshot stuff
// Snapshot single or multiple saves
mySnapSingleCheckbox = new CheckboxWidget(tab, 30, yoffset, 80, kLineHeight,
"Multiple snapshots");
// Activate the first tab
tab->setActiveTab(0);
// Add OK & Cancel buttons
#ifndef MAC_OSX
addButton(_w - 2 *(kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
addButton(_w - (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
#else
addButton(_w - 2 *(kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOkCmd, 0);
#endif
// Create file browser dialog
myBrowser = new BrowserDialog(this, 20, 20, _w - 40, _h - 40);
int baseW = instance()->frameBuffer().baseWidth();
int baseH = instance()->frameBuffer().baseHeight();
myBrowser = new BrowserDialog(this, 60, 20, baseW - 120, baseH - 40);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -87,171 +106,47 @@ LauncherOptionsDialog::~LauncherOptionsDialog()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherOptionsDialog::loadConfig()
{
string romdir = instance()->settings().getString("romdir");
string snapdir = instance()->settings().getString("ssdir");
myRomPath->setLabel(romdir);
mySnapPath->setLabel(snapdir);
/*
string s;
bool b;
int i;
float f;
// Driver setting
myDriverPopup->setSelectedTag(0); // FIXME
s = instance()->settings().getString("romdir");
myRomPath->setLabel(s);
// Renderer setting
s = instance()->settings().getString("video");
if(s == "soft")
myRendererPopup->setSelectedTag(1);
else if(s == "gl")
myRendererPopup->setSelectedTag(2);
s = instance()->settings().getString("ssdir");
mySnapPath->setLabel(s);
// Filter setting
s = instance()->settings().getString("gl_filter");
if(s == "linear")
myFilterPopup->setSelectedTag(1);
else if(s == "nearest")
myFilterPopup->setSelectedTag(2);
s = instance()->settings().getString("ssname");
if(s == "romname")
mySnapTypePopup->setSelectedTag(1);
else if(s == "md5sum")
mySnapTypePopup->setSelectedTag(2);
else
mySnapTypePopup->setSelectedTag(0);
// Aspect ratio - another huge hack
s = instance()->settings().getString("gl_aspect");
f = instance()->settings().getFloat("gl_aspect");
if(f < 1.1)
{
f = 1.1;
s = "1.1";
}
else if(f > 2.0)
{
f = 2.0;
s = "2.0";
}
i = (int)((f * 10) - 10) * 10;
myAspectRatioSlider->setValue(i);
myAspectRatioLabel->setLabel(s);
// Palette
s = instance()->settings().getString("palette");
if(s == "standard")
myPalettePopup->setSelectedTag(1);
else if(s == "original")
myPalettePopup->setSelectedTag(2);
else if(s == "z26")
myPalettePopup->setSelectedTag(3);
// Framerate
myFrameRateSlider->setValue(instance()->settings().getInt("framerate"));
myFrameRateLabel->setLabel(instance()->settings().getString("framerate"));
// Zoom
i = (instance()->settings().getInt("zoom") - 1) * 10;
myZoomSlider->setValue(i);
myZoomLabel->setLabel(instance()->settings().getString("zoom"));
// Fullscreen
b = instance()->settings().getBool("fullscreen");
myFullscreenCheckbox->setState(b);
// Use desktop resolution in fullscreen mode
b = instance()->settings().getBool("gl_fsmax");
myUseDeskResCheckbox->setState(b);
// Make sure that mutually-exclusive items are not enabled at the same time
i = myRendererPopup->getSelectedTag() - 1;
handleRendererChange(i);
*/
b = instance()->settings().getBool("sssingle");
mySnapSingleCheckbox->setState(!b);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherOptionsDialog::saveConfig()
{
cerr << "LauncherOptionsDialog::saveConfig()\n";
/*
string s;
int i;
bool b, restart = false;
bool b;
// Driver setting
s = myDriverPopup->getSelectedString();
if(s != instance()->settings().getString("video_driver"))
{
instance()->settings().setString("video_driver", s);
restart = true;
}
s = myRomPath->getLabel();
instance()->settings().setString("romdir", s);
// Renderer setting
i = myRendererPopup->getSelectedTag();
if(i == 1)
s = "soft";
else if(i == 2)
s = "gl";
if(s != instance()->settings().getString("video"))
{
instance()->settings().setString("video", s);
restart = true;
}
s = mySnapPath->getLabel();
instance()->settings().setString("ssdir", s);
// Filter setting
i = myFilterPopup->getSelectedTag();
if(i == 1)
s = "linear";
else if(i == 2)
s = "nearest";
if(s != instance()->settings().getString("gl_filter"))
{
instance()->settings().setString("gl_filter", s);
restart = true;
}
s = mySnapTypePopup->getSelectedString();
instance()->settings().setString("ssname", s);
// Aspect ratio
s = myAspectRatioLabel->getLabel();
if(s != instance()->settings().getString("gl_aspect"))
{
instance()->settings().setString("gl_aspect", s);
restart = true;
}
b = mySnapSingleCheckbox->getState();
instance()->settings().setBool("sssingle", !b);
// Palette
i = myPalettePopup->getSelectedTag();
if(i == 1)
instance()->settings().setString("palette", "standard");
else if(i == 2)
instance()->settings().setString("palette", "original");
else if(i == 3)
instance()->settings().setString("palette", "z26");
s = myPalettePopup->getSelectedString();
instance()->settings().setString("palette", s);
instance()->console().togglePalette(s);
// Framerate
i = myFrameRateSlider->getValue();
instance()->setFramerate(i);
// Zoom
i = (myZoomSlider->getValue() / 10) + 1;
instance()->settings().setInt("zoom", i);
instance()->frameBuffer().resize(GivenSize, i);
// Fullscreen (the setFullscreen method takes care of updating settings)
b = myFullscreenCheckbox->getState();
instance()->frameBuffer().setFullscreen(b);
// Use desktop resolution in fullscreen mode
b = myUseDeskResCheckbox->getState();
if(b != instance()->settings().getBool("gl_fsmax"))
{
instance()->settings().setBool("gl_fsmax", b);
restart = true;
}
// Finally, issue a complete framebuffer re-initialization
// Not all options may require a full re-initialization, so we only
// do it when necessary
if(restart)
instance()->createFrameBuffer();
*/
// Flush changes to disk
instance()->settings().saveConfig();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: LauncherOptionsDialog.hxx,v 1.2 2005-05-13 18:28:05 stephena Exp $
// $Id: LauncherOptionsDialog.hxx,v 1.3 2005-05-14 03:26:29 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -51,8 +51,8 @@ class LauncherOptionsDialog : public Dialog
// Snapshot controls
StaticTextWidget* mySnapPath;
PopUpWidget* mySnapType;
CheckboxWidget* mySnapSingle;
PopUpWidget* mySnapTypePopup;
CheckboxWidget* mySnapSingleCheckbox;
private:
void openRomBrowser();

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: PopUpWidget.cxx,v 1.8 2005-05-13 18:28:06 stephena Exp $
// $Id: PopUpWidget.cxx,v 1.9 2005-05-14 03:26:29 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -53,8 +53,8 @@ PopUpDialog::PopUpDialog(PopUpWidget* boss, int clickX, int clickY)
// Calculate real popup dimensions
_x = _popUpBoss->getAbsX() + _popUpBoss->_labelWidth;
_y = _popUpBoss->getAbsY() - _popUpBoss->_selectedItem * kLineHeight;
_h = _popUpBoss->_entries.size() * kLineHeight + 2;
_w = _popUpBoss->_w - 10 - _popUpBoss->_labelWidth;
_h = 2; // this will increase as more items are added
// Perform clipping / switch to scrolling mode if we don't fit on the screen
int height = instance()->frameBuffer().baseHeight();
@ -92,16 +92,11 @@ void PopUpDialog::drawDialog()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::handleMouseDown(int x, int y, int button, int clickCount)
{
sendSelection();
_clickX = -1;
_clickY = -1;
_openTime = (int)-1;
if(_popUpBoss->_cmd)
_popUpBoss->sendCommand(_popUpBoss->_cmd, _selection);
// We remove the dialog and delete the dialog when the user has selected an item
parent()->removeDialog();
delete this; // FIXME - this is a memory leak
_openTime = (unsigned int)-1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -139,8 +134,7 @@ void PopUpDialog::handleKeyDown(int ascii, int keycode, int modifiers)
{
case '\n': // enter/return
case '\r':
setResult(_selection);
close();
sendSelection();
break;
case 256+17: // up arrow
moveUp();
@ -187,6 +181,16 @@ void PopUpDialog::setSelection(int item)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::sendSelection()
{
if(_popUpBoss->_cmd)
_popUpBoss->sendCommand(_popUpBoss->_cmd, _selection);
// We remove the dialog when the user has selected an item
parent()->removeDialog();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PopUpDialog::isMouseDown()
{
@ -276,17 +280,23 @@ PopUpWidget::PopUpWidget(GuiObject* boss, int x, int y, int w, int h,
if(!_label.empty() && _labelWidth == 0)
_labelWidth = instance()->frameBuffer().font().getStringWidth(_label);
myPopUpDialog = new PopUpDialog(this, x + getAbsX(), y + getAbsY());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PopUpWidget::~PopUpWidget()
{
delete myPopUpDialog;
myPopUpDialog = NULL;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpWidget::handleMouseDown(int x, int y, int button, int clickCount)
{
if(isEnabled())
{
myPopUpDialog = new PopUpDialog(this, x + getAbsX(), y + getAbsY());
parent()->addDialog(myPopUpDialog);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpWidget::appendEntry(const string& entry, int tag)
@ -295,6 +305,9 @@ void PopUpWidget::appendEntry(const string& entry, int tag)
e.name = entry;
e.tag = tag;
_entries.push_back(e);
// Each time an entry is added, the popup dialog gets larger
myPopUpDialog->setHeight(myPopUpDialog->getHeight() + kLineHeight);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -302,6 +315,9 @@ void PopUpWidget::clearEntries()
{
_entries.clear();
_selectedItem = -1;
// Reset the height of the popup dialog to be empty
myPopUpDialog->setHeight(2);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: PopUpWidget.hxx,v 1.4 2005-05-13 18:28:06 stephena Exp $
// $Id: PopUpWidget.hxx,v 1.5 2005-05-14 03:26:29 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -61,6 +61,7 @@ class PopUpWidget : public Widget, public CommandSender
public:
PopUpWidget(GuiObject* boss, int x, int y, int w, int h,
const string& label, int labelWidth = 0, int cmd = 0);
~PopUpWidget();
void handleMouseDown(int x, int y, int button, int clickCount);
@ -118,6 +119,9 @@ class PopUpDialog : public Dialog
void moveUp();
void moveDown();
private:
void sendSelection();
};
#endif

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: FSNodePOSIX.cxx,v 1.3 2005-05-13 01:03:27 stephena Exp $
// $Id: FSNodePOSIX.cxx,v 1.4 2005-05-14 03:26:29 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -70,6 +70,16 @@ static const char* lastPathComponent(const string& str)
return cur+1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static string validatePath(const string& p)
{
string path = p;
if(p.size() <= 0 || p[0] != '/')
path = "/";
return path;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AbstractFilesystemNode* FilesystemNode::getRoot()
{
@ -79,7 +89,7 @@ AbstractFilesystemNode* FilesystemNode::getRoot()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AbstractFilesystemNode* FilesystemNode::getNodeForPath(const string& path)
{
return new POSIXFilesystemNode(path);
return new POSIXFilesystemNode(validatePath(path));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -98,15 +108,15 @@ POSIXFilesystemNode::POSIXFilesystemNode()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POSIXFilesystemNode::POSIXFilesystemNode(const string& p)
{
Int32 len = 0, offset = p.size();
string path = validatePath(p);
Int32 len = 0, offset = path.size();
struct stat st;
assert(offset > 0);
_path = p;
_path = path;
// Extract last component from path
const char *str = p.c_str();
const char *str = path.c_str();
while (offset > 0 && str[offset-1] == '/')
offset--;
while (offset > 0 && str[offset-1] != '/')