How to resolve the algorithm Rename a file step by step in the ALGOL 68 programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Rename a file step by step in the ALGOL 68 programming language

Table of Contents

Problem Statement

Rename:

This should be done twice:   once "here", i.e. in the current working directory and once in the filesystem root. It can be assumed that the user has the rights to do so. (In unix-type systems, only the user root would have sufficient permissions in the filesystem root.)

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Rename a file step by step in the ALGOL 68 programming language

Source code in the algol programming language

main:(
  PROC rename = (STRING source name, dest name)INT:
  BEGIN
    FILE actual file;
    INT errno = open(actual file, source name, stand back channel);
    IF errno NE 0 THEN
      errno
    ELSE
      IF reidf possible(actual file) THEN
        reidf(actual file, dest name); # change the identification of the book #
        errno
      ELSE
        close(actual file);
        -1
      FI
    FI
  END;
  rename("input.txt", "output.txt");
  rename("/input.txt", "/output.txt");
  rename("docs", "mydocs");
  rename("/docs", "/mydocs")
)

  

You may also check:How to resolve the algorithm Show ASCII table step by step in the OCaml programming language
You may also check:How to resolve the algorithm Real constants and functions step by step in the Chef programming language
You may also check:How to resolve the algorithm Euler's sum of powers conjecture step by step in the C++ programming language
You may also check:How to resolve the algorithm Largest int from concatenated ints step by step in the PowerShell programming language
You may also check:How to resolve the algorithm Dragon curve step by step in the SequenceL programming language