Esempio n. 1
0
    def dePrintEntryInfo(self):
        """Print information about this directory entry."""

        print rad50.rad50ToFilename(self.deName) + ":"
        print "  status  = " + statWordToStr(self.deStatus)
        print "  length  = " + str(self.deLength)
        print "  start   = " + str(self.deStart)
        print "  date    = " + rt11util.dateWordToStr(self.deDate)
        print "  jobchan = " + str(self.deJobChan)
        print "  extra   = " + str(self.deExtra)
Esempio n. 2
0
    def dePrintDirEntry(self, long_format=False, omit_perm_flag=True):
        """Print directory listing line for this directory entry."""

        dirline = (
            rad50.rad50ToFilename(self.deName).ljust(12)
            + str(self.deLength).rjust(8)
            + rt11util.dateWordToStr(self.deDate).rjust(14)
        )

        if long_format:
            dirline = dirline + str(self.deStart).rjust(8) + "  " + statWordToStr(self.deStatus, omit_perm_flag)
        print dirline
Esempio n. 3
0
    def fsSaveFile(self, rtFilename, hostFilename=""):
        """Save permanent file with specified name to host filesystem.

        If hostFilename is not specified, RT-11 filename will be used
        and file will be saved in current directory. If host filename
        is specified, it may include a relative or absolute path."""

        r50Name = rad50.filenameToRad50(rtFilename)
        rtFilename = rad50.rad50ToFilename(r50Name)

        savedFile = False
        for de in self.fsFileList:
            if (de.deStatus & deEPERM) and (de.deName == r50Name):
                savedFile = True
                de.deSaveFile(hostFilename)
                break
        rt11util.assertWarn(savedFile, "Could not find file " + rtFilename)
Esempio n. 4
0
    def deSaveFile(self, hostFilename=""):
        """Save to a file on the host computer filesystem.

        hostFilename argument specifies the filename to create on the
        host filesystem.
        If name for host file is not specified, RT-11 filename will
        be used, and the file will be saved in the current directory.
        If host filename is specified, it may include a relative
        or absolute path in order to save the file outside the current
        directory."""

        if hostFilename == "":
            hostFilename = rad50.rad50ToFilename(self.deName)

        f = open(hostFilename, "wb")
        f.write(self.deData)
        f.close
Esempio n. 5
0
    def fsAddFile(self, hostFilename, rtFilename="", dateWord=None, statusWord=deEPERM):
        """Read file and add it to the RT-11 filesystem.

        hostFilename refers to a local file on the host's filesystem.
        If rtFilename is not specified, filename on RT-11 filesystem will
        be derived from hostFilename.
        If host file size is not a multiple of rtBlockSize, it will be
        padded with zeroes.
        Negative dateWord will be replaced with today's date."""

        # Use host filename if RT-11 name not specified
        if rtFilename == "":
            rtFilename = hostFilename

        rad50Filename = rad50.filenameToRad50(rtFilename)
        rtFilename = rad50.rad50ToFilename(rad50Filename)

        if dateWord is None:
            dateWord = rt11util.todayWord(self.fsThisYear)

        # Read host file, pad if necessary
        f = open(hostFilename, "rb")
        buf = f.read()
        f.close
        pad = rt11util.rtBlockSize - (len(buf) % rt11util.rtBlockSize)
        if pad != 512:
            buf += "\000" * pad
        fileLen = len(buf) / rt11util.rtBlockSize

        # Delete existing file with same name
        self.fsDeleteFile(rtFilename)

        # Search for first empty block large enough to hold file
        addedFile = False
        for idx, de in enumerate(self.fsFileList):
            if (de.deStatus & deEMPTY) and (de.deLength >= fileLen):
                addedFile = True

                # If empty block is larger than new file, split it.
                if de.deLength > fileLen:
                    ede = dirEntry(
                        name=rad50.filenameToRad50(" EMPTY.FIL"),
                        length=de.deLength - fileLen,
                        start=de.deStart + fileLen,
                        status=deEMPTY,
                        date=rt11util.todayWord(self.fsThisYear),
                    )
                    ede.deEmptyData()
                    self.fsFileList.insert(idx + 1, ede)

                de.deStatus = statusWord
                de.deName = rad50Filename
                de.deLength = fileLen
                de.deJobChan = 0
                de.deDate = dateWord
                de.deSetData(buf)

                self.fsFileList[idx] = de
                break

        rt11util.assertError(addedFile, "Could not find space for " + rtFilename)
Esempio n. 6
0
 def dePrintName(self):
     """Print the filename."""
     print rad50.rad50ToFilename(self.deName)