Skip to content

Conversation

@madebr
Copy link
Collaborator

@madebr madebr commented Apr 27, 2023

  • CMake will drop support for cmake scripts < 3.5, so bump it to 3.5
  • Use rpath for the executables, such that test_physfs uses the newly built libphysfs.so library, instead of the system library.
    These paths are removed when they are installed.
  • Use the alias'ed targets
  • Treat arguments as interactive commands.
    This allows to run commands from the shell without requiring to put them in a file.
    This was useful while developing in the IDE, not needing to manually enter something.
    This allows e.g. ./test_physfs "mount /tmp/data_tree /tt 0" "ls /tt" "quit"
  • Add a tree command to test_physfs. This works more or less similar to the unix tree command: non-accessible files are ignored + symlinks are not entered.

The following comands:

cat <<EOF >tree.sh
#!/bin/sh

set -e

PARENT=\$(pwd)/data_tree

function create_tree() {
  local i
  if test \$1 -ne 0; then
    for i in \$(seq \$2); do
      mkdir -p "dir\$i"
      pushd "dir\$i" >/dev/null
      create_tree \$(expr \$1 - 1 ) \$2
      popd >/dev/null
      if test \$i -eq 2; then
        chmod 0 dir\$i
      fi
    done
    ln -s "\$PARENT" dir\$(expr \$2 + 1)
  fi
  for i in \$(seq \$2); do
    echo "file\$1" >"file\$i"
  done
}

sudo rm -rf "\$PARENT"
mkdir "\$PARENT"
pushd "\$PARENT" >/dev/null
create_tree 3 3
popd >/dev/null
EOF

sh tree.sh
./test_physfs "mount $PWD/data_tree /tt 0" "tree /tt" "quit"

will output:

...
Enter commands. Enter "help" for instructions.
Successful.
/tt
├── dir1
│   ├── dir1
│   │   ├── dir1
│   │   │   ├── file1
│   │   │   ├── file2
│   │   │   └── file3
│   │   ├── dir2 [Failure. reason: permission denied]
│   │   ├── dir3
│   │   │   ├── file1
│   │   │   ├── file2
│   │   │   └── file3
│   │   ├── file1
│   │   ├── file2
│   │   └── file3
│   ├── dir2 [Failure. reason: permission denied]
│   ├── dir3
│   │   ├── dir1
│   │   │   ├── file1
│   │   │   ├── file2
│   │   │   └── file3
│   │   ├── dir2 [Failure. reason: permission denied]
│   │   ├── dir3
│   │   │   ├── file1
│   │   │   ├── file2
│   │   │   └── file3
│   │   ├── file1
│   │   ├── file2
│   │   └── file3
│   ├── file1
│   ├── file2
│   └── file3
├── dir2 [Failure. reason: permission denied]
├── dir3
│   ├── dir1
│   │   ├── dir1
│   │   │   ├── file1
│   │   │   ├── file2
│   │   │   └── file3
│   │   ├── dir2 [Failure. reason: permission denied]
│   │   ├── dir3
│   │   │   ├── file1
│   │   │   ├── file2
│   │   │   └── file3
│   │   ├── file1
│   │   ├── file2
│   │   └── file3
│   ├── dir2 [Failure. reason: permission denied]
│   ├── dir3
│   │   ├── dir1
│   │   │   ├── file1
│   │   │   ├── file2
│   │   │   └── file3
│   │   ├── dir2 [Failure. reason: permission denied]
│   │   ├── dir3
│   │   │   ├── file1
│   │   │   ├── file2
│   │   │   └── file3
│   │   ├── file1
│   │   ├── file2
│   │   └── file3
│   ├── file1
│   ├── file2
│   └── file3
├── file1
├── file2
└── file3

21 directories, 45 files

(I don't know why no symbolic links show up)

madebr added 5 commits April 27, 2023 22:39
This avoid test_physfs using a system libphysfs library instead of a newly built one.
This makes it easier to debug test_physfs: no need to enter something in the terminal.
Symbolic links are not followed.
@icculus
Copy link
Owner

icculus commented Apr 27, 2023

(I don't know why no symbolic links show up)

PhysicsFS explicitly ignores symlinks by default. Try this:

./test_physfs "permitsymlinks 1" "mount $PWD/data_tree /tt 0" "tree /tt" "quit"

Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
@madebr
Copy link
Collaborator Author

madebr commented Apr 27, 2023

Yup, that works.

/tt
├── dir1
│   ├── dir1
│   │   ├── dir1
│   │   │   ├── file1
│   │   │   ├── file2
│   │   │   └── file3
│   │   ├── dir2 [Failure. reason: permission denied]
│   │   ├── dir3
│   │   │   ├── file1
│   │   │   ├── file2
│   │   │   └── file3
│   │   ├── dir4 [symbolic link]
│   │   ├── file1
│   │   ├── file2
│   │   └── file3
│   ├── dir2 [Failure. reason: permission denied]
│   ├── dir3
│   │   ├── dir1
│   │   │   ├── file1
│   │   │   ├── file2
│   │   │   └── file3
│   │   ├── dir2 [Failure. reason: permission denied]
│   │   ├── dir3
│   │   │   ├── file1
│   │   │   ├── file2
│   │   │   └── file3
│   │   ├── dir4 [symbolic link]
│   │   ├── file1
│   │   ├── file2
│   │   └── file3
│   ├── dir4 [symbolic link]
│   ├── file1
│   ├── file2
│   └── file3
├── dir2 [Failure. reason: permission denied]
├── dir3
│   ├── dir1
│   │   ├── dir1
│   │   │   ├── file1
│   │   │   ├── file2
│   │   │   └── file3
│   │   ├── dir2 [Failure. reason: permission denied]
│   │   ├── dir3
│   │   │   ├── file1
│   │   │   ├── file2
│   │   │   └── file3
│   │   ├── dir4 [symbolic link]
│   │   ├── file1
│   │   ├── file2
│   │   └── file3
│   ├── dir2 [Failure. reason: permission denied]
│   ├── dir3
│   │   ├── dir1
│   │   │   ├── file1
│   │   │   ├── file2
│   │   │   └── file3
│   │   ├── dir2 [Failure. reason: permission denied]
│   │   ├── dir3
│   │   │   ├── file1
│   │   │   ├── file2
│   │   │   └── file3
│   │   ├── dir4 [symbolic link]
│   │   ├── file1
│   │   ├── file2
│   │   └── file3
│   ├── dir4 [symbolic link]
│   ├── file1
│   ├── file2
│   └── file3
├── dir4 [symbolic link]
├── file1
├── file2
└── file3

@icculus icculus merged commit 957176b into icculus:main Apr 27, 2023
@madebr madebr deleted the cmake-tree branch April 28, 2023 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants