diff --git a/setup/installer/windows/portable.c b/setup/installer/windows/portable.c
index b07afea9dc..a63c319cda 100644
--- a/setup/installer/windows/portable.c
+++ b/setup/installer/windows/portable.c
@@ -53,7 +53,7 @@ void show_last_error(LPCTSTR preamble) {
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- &msg,
+ (LPTSTR)&msg,
0, NULL );
show_detailed_error(preamble, msg, (int)dw);
@@ -136,7 +136,7 @@ void launch_calibre(LPCTSTR exe, LPCTSTR config_dir, LPCTSTR library_dir) {
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
- LPTSTR app_dir, config_dir, exe, library_dir;
+ LPTSTR app_dir, config_dir, exe, library_dir, too_long;
app_dir = get_app_dir();
config_dir = (LPTSTR)calloc(BUFSIZE, sizeof(TCHAR));
@@ -147,7 +147,15 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
_sntprintf_s(exe, BUFSIZE, _TRUNCATE, _T("%sCalibre\\calibre.exe"), app_dir);
_sntprintf_s(library_dir, BUFSIZE, _TRUNCATE, _T("%sCalibre Library"), app_dir);
- launch_calibre(exe, config_dir, library_dir);
+ if ( _tcscnlen(library_dir, BUFSIZE) <= 74 ) {
+ launch_calibre(exe, config_dir, library_dir);
+ } else {
+ too_long = (LPTSTR)calloc(BUFSIZE+300, sizeof(TCHAR));
+ _sntprintf_s(too_long, BUFSIZE+300, _TRUNCATE,
+ _T("Path to Calibre Portable (%s) too long. Must be less than 59 characters."), app_dir);
+
+ show_error(too_long);
+ }
free(app_dir); free(config_dir); free(exe); free(library_dir);
diff --git a/src/calibre/gui2/wizard/__init__.py b/src/calibre/gui2/wizard/__init__.py
index 4865d882b7..097bf0707f 100644
--- a/src/calibre/gui2/wizard/__init__.py
+++ b/src/calibre/gui2/wizard/__init__.py
@@ -16,7 +16,8 @@ from PyQt4.Qt import (QWizard, QWizardPage, QPixmap, Qt, QAbstractListModel,
from calibre import __appname__, patheq
from calibre.library.database2 import LibraryDatabase2
from calibre.library.move import MoveLibrary
-from calibre.constants import filesystem_encoding, iswindows, plugins
+from calibre.constants import (filesystem_encoding, iswindows, plugins,
+ isportable)
from calibre.gui2.wizard.send_email import smtp_prefs
from calibre.gui2.wizard.device_ui import Ui_WizardPage as DeviceUI
from calibre.gui2.wizard.library_ui import Ui_WizardPage as LibraryUI
@@ -769,6 +770,10 @@ class LibraryPage(QWizardPage, LibraryUI):
traceback.print_exc()
lp = os.path.expanduser(u'~')
self.location.setText(lp)
+ # Hide the library location settings if we are a portable install
+ for x in ('location', 'button_change', 'libloc_label1',
+ 'libloc_label2'):
+ getattr(self, x).setVisible(not isportable)
def isComplete(self):
try:
diff --git a/src/calibre/gui2/wizard/library.ui b/src/calibre/gui2/wizard/library.ui
index 4c70f8c561..c0ed20f773 100644
--- a/src/calibre/gui2/wizard/library.ui
+++ b/src/calibre/gui2/wizard/library.ui
@@ -34,7 +34,7 @@
-
-
+
<p>Choose a location for your books. When you add books to calibre, they will be copied here. Use an <b>empty folder</b> for a new calibre library:
@@ -58,7 +58,7 @@
-
-
+
If you have an existing calibre library, it will be copied to the new location. If a calibre library already exists at the new location, calibre will switch to using it.