Skip to content

Commit

Permalink
Added code to delete gigantic log file.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahlstromcj committed May 28, 2023
1 parent e178099 commit d5ef4a2
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 38 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# README for Seq66 0.99.6 2023-05-25
# README for Seq66 0.99.6 2023-05-28

__Seq66__: MIDI sequencer/live-looper with a hardware-sampler grid interface;
pattern banks and triggers, and playlists for song management; a scale and
Expand Down Expand Up @@ -93,13 +93,16 @@ Windows, and using a conventional source tarball.
arrow keys work only if the seqroll has keyboard focus.
* Follow-ons to issue #110:
* Addition of Start menu entries for Windows.
* Added data/readme files and doc/tutorial files accidentally
left out of NSIS installer.
* Fixed event::is_desired(), which affected changing note
velocities in the pattern editor's data pane.
* Fixed an error preventing changing the "background" pattern.
* Added 'o' keystroke to seqroll to toggle recording ('r' already
used to randomize notes).
* Refactored access to manual and tutorial for robustness.
* At first start, a log-file is automatically created.
* At first start, a log-file is now automatically created. If it
gets larger than a megabyte, then it is deleted to start over.
* Version 0.99.5:
* Greatly enhanced the event editor tab and the events that can
be view and modified.
Expand Down
16 changes: 13 additions & 3 deletions Seq66qt5/Seq66qt5.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# \library seq66qt5 application
# \author Chris Ahlstrom
# \date 2018-04-08
# \update 2023-05-26
# \update 2023-05-27
# \version $Revision$
# \license $XPC_SUITE_GPL_LICENSE$
#
Expand Down Expand Up @@ -134,8 +134,18 @@ windows: LIBS += -lwinmm

# Install an application icon for Windows to use.

win32:RC_ICONS += ../resources/icons/route66.ico
windows:RC_ICONS += ../resources/icons/route66.ico
win32:RC_ICONS += ../resources/icons/route66.ico \
../resources/icons/route66-16x16.ico \
../resources/icons/route66-32x32.ico \
../resources/icons/route66-48x48.ico \
../resources/icons/route66-64x64.ico \
../resources/icons/route66-256x256.ico
windows:RC_ICONS += ../resources/icons/route66.ico \
../resources/icons/route66-16x16.ico \
../resources/icons/route66-32x32.ico \
../resources/icons/route66-48x48.ico \
../resources/icons/route66-64x64.ico \
../resources/icons/route66-256x256.ico

#******************************************************************************
# Seq66qt5.pro (Seq66qt5)
Expand Down
16 changes: 9 additions & 7 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
TO DO for Seq66 0.99.6 (Sequencer64 refactored for C++14 and Qt)
Chris Ahlstrom
2019-04-13 to 2023-05-24
2019-04-13 to 2023-05-27

Some of these issues will be pushed off for the distant Seq66v2.

Current:
Current ("o" = we think it is fixed):

- Windows: No shortcut in Start menu after setup.
o Windows: No shortcut in Start menu after setup.
- User manual and tutorials entry menus seems to open something but close
quick (I do have a default pdf reader).
- Fixed: Tempo is not saved with new song (but works with for example
o Fixed: Tempo is not saved with new song (but works with for example
Kraftwerk-Europe_Endless-reconstructed.midi provided in data folder).
- Investigate: cannot click on 'MIDI Clock' tab in preferences (alt-C OK).

Patterns editor:

- Fixed: Often Ctrl-Z is not working event though click undo button works.
- Fixed: No undo on velocity changes. Works, but was not always seen,
o Fixed: Often Ctrl-Z is not working event though click undo button works.
o Fixed: No undo on velocity changes. Works, but was not always seen,
had to set a dirty status.
- Fixed:When a background sequence is chosen, it is not possible to display
o Fixed: When a background sequence is chosen, it is not possible to display
another one or to turn it off.
- Why does velocity change in data pane not work when starting from the
left in barrage.midi, but work okay when starting from the right?

Added code to pass arrow events from the qscrollslave to the
qscrollmaster. Does not work for wheel events, oddly enough.
Expand Down
9 changes: 7 additions & 2 deletions libseq66/include/util/filefunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*
* \author Chris Ahlstrom
* \date 2015-11-20
* \updates 2023-05-10
* \updates 2023-05-28
* \version $Revision$
*
* Also see the filefunctions.cpp module. The functions here use
Expand Down Expand Up @@ -59,7 +59,12 @@ extern bool file_executable (const std::string & targetfile);
extern bool file_is_directory (const std::string & targetfile);
extern bool file_name_good (const std::string & filename);
extern bool file_mode_good (const std::string & mode);
extern std::FILE * file_open (const std::string & filename, const std::string & mode);
extern size_t file_size (const std::string & filename);
extern std::FILE * file_open
(
const std::string & filename,
const std::string & mode
);
extern std::FILE * file_open_for_read (const std::string & filename);
extern std::FILE * file_create_for_write (const std::string & filename);
extern std::string current_date_time ();
Expand Down
11 changes: 8 additions & 3 deletions libseq66/src/midi/midifile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2015-07-24
* \updates 2023-05-06
* \updates 2023-05-28
* \license GNU GPLv2 or above
*
* For a quick guide to the MIDI format, see, for example:
Expand Down Expand Up @@ -641,14 +641,18 @@ midifile::read_gap (size_t sz)
bool
midifile::grab_input_stream (const std::string & tag)
{
if (m_name.empty())
return false;
m_file_size = file_size(m_name);
if (m_name.empty() || m_file_size == 0)
{
return set_error("Bad MIDI file");
}

std::ifstream file(m_name, std::ios::in | std::ios::binary | std::ios::ate);
bool result = file.is_open();
m_error_is_fatal = false;
if (result)
{
#if defined USE_OLD_CODE
try
{
(void) file.seekg(0, file.end); /* seek to the file's end */
Expand All @@ -658,6 +662,7 @@ midifile::grab_input_stream (const std::string & tag)
{
m_file_size = 0;
}
#endif
if (m_file_size < c_minimum_midi_file_size)
{
result = set_error("File too small");
Expand Down
24 changes: 21 additions & 3 deletions libseq66/src/sessions/smanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2020-03-22
* \updates 2023-05-25
* \updates 2023-05-28
* \license GNU GPLv2 or above
*
* Note that this module is part of the libseq66 library, not the libsessions
Expand Down Expand Up @@ -113,6 +113,24 @@ smanager::~smanager ()
session_message("Exiting session manager");
}

/**
* This function also checks to make sure the log file does not get too large
* (about a megabyte).
*/

static void
reroute_to_log (const std::string & filepath)
{
static const size_t s_limit = 1048576;
size_t sz = file_size(filepath);
if (sz > s_limit)
{
(void) file_delete(filepath);
session_message("Log file deleted", filepath);
}
(void) reroute_stdio(filepath);
}

/**
* The first thing is to set the various settings defaults, and then read
* the 'usr' and 'rc' configuration files, in that order. The last thing
Expand Down Expand Up @@ -256,7 +274,7 @@ smanager::main_settings (int argc, char * argv [])

std::string logfile = usr().option_logfile();
if (usr().option_use_logfile())
(void) reroute_stdio(logfile);
reroute_to_log(logfile);

m_midi_filename.clear();
if (optionindex > 0 && optionindex < argc) /* MIDI filename? */
Expand Down Expand Up @@ -979,7 +997,7 @@ smanager::create_configuration
{
usr().option_logfile("seq66.log");
usr().option_use_logfile(true);
(void) reroute_stdio(usr().option_logfile());
reroute_to_log(usr().option_logfile());
result = make_directory_path(mainpath);
if (result)
{
Expand Down
56 changes: 46 additions & 10 deletions libseq66/src/util/filefunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2015-11-20
* \updates 2023-05-11
* \updates 2023-05-28
* \version $Revision$
*
* We basically include only the functions we need for Seq66, not
Expand Down Expand Up @@ -491,13 +491,13 @@ file_writable (const std::string & filename)
}

/**
* Checks a file for readability and writability. An even stronger test
* than file_exists. At present, we see no need to distinguish read and
* write permissions. We assume the file is fully accessible only if the
* file has both permissions.
* Checks a file for readability and writability. An even stronger test than
* file_exists. At present, we see no need to distinguish read and write
* permissions. We assume the file is fully accessible only if the file has
* both permissions.
*
* This can be surprising if one wants only to read a file, and the file is
* read-only.
* This can be surprising if one wants only to read a file, and the file is
* read-only.
*
* \param filename
* Provides the name of the file to be checked.
Expand All @@ -513,7 +513,7 @@ file_read_writable (const std::string & filename)
}

/**
* Checks a file for the ability to be executed.
* Checks a file for the ability to be executed.
*
* \param filename
* Provides the name of the file to be checked.
Expand Down Expand Up @@ -550,8 +550,8 @@ file_executable (const std::string & filename)
}

/**
* Checks a file to see if it is a directory. This function is also used
* in the function of the same name in fileutilities.cpp.
* Checks a file to see if it is a directory. This function is also used in
* the function of the same name in fileutilities.cpp.
*
* \param filename
* Provides the name of the directory to be checked.
Expand Down Expand Up @@ -582,6 +582,42 @@ file_is_directory (const std::string & filename)
return result;
}

/**
* Determines the size of a file. An alternative, but apparently less
* reliable method is the following, which apparently needs to be put in a
* try-catch block.
*
* std::ifstream file(m_name, std::ios::in | std::ios::binary | std::ios::ate);
* bool result = file.is_open();
* (void) file.seekg(0, file.end); // seek to the file's end
* m_file_size = file.tellg(); // get the end offset
*
* Another option is to #include <filesystem> and call
* std::uintmax_t file_size (const std::filesystem::path& p), which
* throws (but there is a noexcept version as well.
*
* \param filename
* The name of the file. If it is a directory, this function will fail.
*
* \return
* Returns the size of the file or 0 if the file is of size 0 or is
* not a file.
*/

size_t
file_size (const std::string & filename)
{
size_t result = 0;
if (file_name_good(filename))
{
stat_t statusbuf;
int statresult = S_STAT(filename.c_str(), &statusbuf);
if (statresult == 0) // a good file handle?
result = statusbuf.st_size;
}
return result;
}

/**
* Verifies that a file-name pointer is legal. The following checks are
* made:
Expand Down
43 changes: 39 additions & 4 deletions nsis/Seq66Setup.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
; File: Seq66Setup.nsi
; Author: Chris Ahlstrom
; Date: 2018-05-26
; Updated: 2023-05-24
; Updated: 2023-05-28
; Version: 0.99.6
;
; Usage of this Windows build script:
;
; - See the build_release_package.bat file for full details.
; - Obtain and install the NSIS 2.46 (or above) installer from
; http://nsis.sourceforge.net/Download, or preferably install it from
; your Linux repository via apt.
; your Linux repository via apt. It can also be installed on
; Windows, and the build script can detect if it is available on
; the PATH.
; - In Windows, Check out the latest branch project from Git. Or
; make a source package using the handy "pack" script on Linux,
; and copy the source package to your Windows system, and unpack it
Expand All @@ -35,12 +37,15 @@
; "Test Installer" button in the NSIS window.
; - When you get to the "Choose Install Location" window, you can
; use "C" and test the installation.
; - Or, as in Linux, the makensis command can be used if
; available.
; - Linux: The program that creates Windows installers on Linux is
; 'makensis'.
; - The actual build is done on Windows.
; - Change to the "seq66/nsis" directory.
; - Run "makensis Seq66Setup_V0.95.nsi" (or current version).
; - The installer package is located at "...."
; - Run "makensis Seq66Setup.nsi".
; - After creation, The installer package is at
; "seq66/release/seq66_setup_x64-0.99.5.exe" or similar.
; - Select the defaults and let the installer do its thing.
; - To uninstall the application, use Settings /
; Control Panel / Add and Remove Programs. The application is
Expand Down Expand Up @@ -97,6 +102,36 @@ Unicode True
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES

;---------------------------------------------------------------------------
; Tentative code to install a desktop icon. Disabls the readme prompt and
; uses it to prompt for installing a desktop icon
;
; Function finishpageaction
; CreateShortcut "$DESKTOP\qpseq66.lnk" "$iNSTDIR\qpseq66.exe"
; FunctionEnd
;
; !define MUI_FINISHPAGE_SHOWREADME ""
; !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
; !define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Desktop Shortcut"
; !define MUI_FINISHPAGE_SHOWREADME_FUNCTION finishpageaction
;
;----------------------------
;
; Uninstall:
;
; Removes pins using the shortcut.
; Deletes the shortcut.
; Refreshes the desktop.
;
; !macro customInstall WinShell::UninstShortcut "$desktopLink"
;
; Delete "$desktopLink"
; System::Call 'shell32::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
;
; !macroend
;
;---------------------------------------------------------------------------

!define MUI_FINISHPAGE_SHOWREADME "..\data\readme.text"
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_INSTFILES
Expand Down
8 changes: 4 additions & 4 deletions seq66.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# \library qpseq66 application
# \author Chris Ahlstrom
# \date 2018-11-15
# \update 2023-05-26
# \update 2023-05-27
# \version $Revision$
# \license $XPC_SUITE_GPL_LICENSE$
#
Expand Down Expand Up @@ -49,9 +49,9 @@ message("SUBDIRS is set to: $${SUBDIRS}")

QMAKE_CXXFLAGS += -std=c++14

# Install an application icon for Windows to use.

win32:RC_ICONS += ../seq66/resources/icons/route66.ico
# Install an application icon for Windows to use. But see Seq66qt5.pro instead.
#
# win32:RC_ICONS += ../seq66/resources/icons/route66.ico

# win32:RC_FILE = resources/seq66_win.rc
# RESOURCES += seq66.qrc
Expand Down

0 comments on commit d5ef4a2

Please sign in to comment.