Page 1 of 1

Invalid Workspace Archive

Posted: Tue Jan 07, 2014 6:40 pm
by kengrubb
I have been encountering this from time to time since upgrading to TP 7.1.0

I get the error message when opening a Workspace file (*.tws), and the Workspace gets trashed.

Posted: Tue Jan 07, 2014 6:46 pm
by kengrubb
I saved off my Workspaces so I didn't lose them. Error message I'm seeing, which is reproducible, when I double click the Workspace (.tws) is:

Unexpected problem loading workspace archive.
Cannot restore full workspace.

Posted: Tue Jan 07, 2014 7:34 pm
by kengrubb
If I open up TextPad with another Workspace, then open this Workspace via File, Workspace, Open or the hotlist, then it's fine. However, once the Workspace updates, it's corrupted.

Posted: Tue Jan 07, 2014 8:18 pm
by kengrubb
One thing I can observe would be that I believe the corrupted Workspace was created and/or saved under TP 7.0.9 running out of C:\Program Files (x86) whereas TP 7.1.0 installed in C:\Program Files

Posted: Wed Jan 22, 2014 7:41 pm
by kengrubb
Still periodically getting these. Workspaces are somehow getting corrupted.

Posted: Thu Jan 23, 2014 11:02 pm
by kengrubb
This is happening now daily, and it's quite maddening.

Posted: Fri Jan 31, 2014 12:27 am
by kengrubb
OK, I may have figured out the pattern.

It appears that if one has a Workspace with a file open in it, and the file gets moved to a different folder, either when TP closes, or when TP opens again, the Workspace becomes invalid because it has a link to a file which no longer exists.

Posted: Fri Jan 31, 2014 1:53 pm
by ben_josephs
I believe this happened to me once with TextPad 7, although I haven't been able to reproduce it.

I have a Perl script that lists the file names in a TextPad workspace file. I keep my large and growing collection of workspace files in a single directory, and I use this script to find out in which workspace I long ago edited some particular half-forgotten file. Might it be useful to you (or anyone else)?

Posted: Sun Feb 02, 2014 7:29 pm
by kengrubb
It would be useful to me, and I suspect useful to others

Posted: Sun Feb 02, 2014 9:33 pm
by ben_josephs
The script twsfiles.pl below assumes that your workspaces are in the directory C:/t .

To list all the files in workspace aWorkspace enter
perl twsfiles.pl aWorkspace.tws

To list all the files in all workspaces matching wildcard expression wildcard_expression enter
perl twsfiles.pl wildcard_expression

To list all the files in all workspaces enter
perl twsfiles.pl

Code: Select all

use warnings ;
use strict   ;

use Encode ;
use File::Glob ':glob' ;

my $twsDir = 'C:/t' ;

chdir $twsDir or
  die "Can't change to directory \"$twsDir\": $!\n" ;

my @twsNames = map { bsd_glob $_ } ( @ARGV ? @ARGV : ( '*.tws' ) ) ;

for my $twsName ( @twsNames )
{
  if ( -f $twsName && $twsName =~ /\.tws$/ )
  {
    print "\n$twsName\n" ;

    if ( open TWS, $twsName )
    {
      local $/ = undef ;
      my $tws = <TWS> ;
      close TWS ;

      if ( ( ord substr $tws, 2, 1 ) >= 7 )  # new-style (UTF-16) workspace file
      {
        my @docNames = $tws =~ /[EB]COD.{5}((?:..)+?)\x00\x00/gs ;

        for my $docName ( sort @docNames )
        {
          print +( decode 'ucs-2le', $docName ), "\n" ;
        }
      }
      else                                   # old-style (ASCII) workspace file
      {
        my @docNames = $tws =~ /[EB]COD..(.+?)\x00/gs ;

        for my $docName ( sort @docNames )
        {
          print "$docName\n" ;
        }
      }
    }
    else
    {
      warn "Can't open \"$twsName\".\n" ;
    }
  }
  elsif ( -f $twsName )
  {
    print "\n\"$twsName\" is not a workspace file.\n" ;
  }
  else
  {
    print "\n\"$twsName\" doesn't exist.\n" ;
  }
}