Skip to content

Commit c4db760

Browse files
author
adrianbartyczak
committed
Update example file paths in Locatefile
1 parent 02f4c22 commit c4db760

File tree

8 files changed

+54
-97
lines changed

8 files changed

+54
-97
lines changed

file_management/file_retrieval/locatefile/README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,27 @@ Locatefile uses two databases consisting of text files: one for file and one for
1919
locatefile my-doc # returns "/home/user/documents/my-document.txt"
2020
```
2121

22-
*Any part of the file name can be used; the first match will be returned*
22+
Any part of a file name can be used to find a file; the first match will be returned.
2323

2424
```bash
25-
locatefile shr # returns "/home/user/.bashrc"
25+
locatefile roj # returns "/home/user/archives/backup/projects.txt"
2626
```
2727

28-
*A file can be located in a mounted drive (see the MOUNTPOINT_PATHS variable in [configurations](configurations) for more information)*
28+
A file can be located in a mounted drive (see the MOUNTPOINT_PATHS variable in [configurations](configurations) for more information).
2929

3030
```bash
31-
locatefile stat # returns "MNTPNT_PATH/records/external/statistics.txt" (if the drive containing the
32-
# file is mounted), where "MNTPNT_PATH" is the mountpoint of the mounted drive
31+
locatefile my-note # returns "MNTPNT_PATH/general/notes/my-notes.txt" (if the drive containing the
32+
# file is mounted), where "MNTPNT_PATH" is the mountpoint of the mounted drive
3333
```
3434

3535
### 2. Locate a directory
3636

3737
```bash
38-
locatefile -d tur # returns "/home/user/pictures"
38+
locatefile -d arc # returns "/home/user/archives"
3939
```
4040

41+
Locate file rules apply.
42+
4143
## Usage
4244

4345
1. Adjust the configurations in [configurations](configurations).
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
/home/user/documents
2+
/home/user/archives
3+
/home/user/archives/backups
4+
/home/user/archives/save
25
/home/user/bin
3-
/home/user/share
4-
/home/user/pictures
5-
/home/user/archived_data
6+
/home/user/bin/my-scripts
7+
/home/user/bin/utilities
8+
/home/user/bin/utilities/file-parsers
9+
/home/user/bin/utilities/tests
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{MNTPNT_PATH}/general
2-
{MNTPNT_PATH}/general/archive
2+
{MNTPNT_PATH}/general/archives
33
{MNTPNT_PATH}/general/reference
4-
{MNTPNT_PATH}/general/notes
54
{MNTPNT_PATH}/current
6-
{MNTPNT_PATH}/current/notes
7-
{MNTPNT_PATH}/records
8-
{MNTPNT_PATH}/bookmarks
5+
{MNTPNT_PATH}/current/primary
6+
{MNTPNT_PATH}/current/save
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{MNTPNT_PATH}/components/main
22
{MNTPNT_PATH}/components/main/configurations/default
33
{MNTPNT_PATH}/components/main/configurations/webapp
4-
{MNTPNT_PATH}/components/main/resources
54
{MNTPNT_PATH}/global
65
{MNTPNT_PATH}/global/resources
Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
1-
/home/user/documents/tasks.txt
2-
/home/user/documents/recent_scores.txt
31
/home/user/documents/my-document.txt
4-
/home/user/.bashrc
5-
/home/user/.bash_profile
6-
/home/user/.vimrc
7-
/home/user/.ssh/config
8-
/home/user/bin/configuration.sh
9-
/home/user/bin/startup.sh
10-
/home/user/share/calendar/events.txt
11-
/home/user/pictures/mountains-1.jpeg
12-
/home/user/pictures/mountains-2.jpeg
13-
/home/user/pictures/art/abstract-yellow.jpeg
14-
/home/user/pictures/art/abstract-orange.jpeg
15-
/home/user/archived_data/backup/bookmarks.html
16-
/home/user/archived_data/backup/contacts.html
2+
/home/user/archives/backup/projects.txt
3+
/home/user/archives/backup/contacts.txt
4+
/home/user/bin/my-test-runner.sh
5+
/home/user/bin/saved/my-configurator.sh
Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
1-
{MNTPNT_PATH}/general/notes/assignment.txt
2-
{MNTPNT_PATH}/general/archive/dh.png
3-
{MNTPNT_PATH}/general/archive/dh2.png
4-
{MNTPNT_PATH}/general/archive/dh3.png
5-
{MNTPNT_PATH}/general/archive/tmp.png
6-
{MNTPNT_PATH}/general/reference/primary.txt
7-
{MNTPNT_PATH}/general/reference/secondary.txt
8-
{MNTPNT_PATH}/general/reference/website_urls.txt
9-
{MNTPNT_PATH}/other/finished_tasks.txt
10-
{MNTPNT_PATH}/finance/invoice1.txt
11-
{MNTPNT_PATH}/finance/invoice2.txt
12-
{MNTPNT_PATH}/finance/invoice3.txt
13-
{MNTPNT_PATH}/finance/payments.txt
1+
{MNTPNT_PATH}/general/notes/my-notes.txt
142
{MNTPNT_PATH}/current/todo.txt
15-
{MNTPNT_PATH}/current/general/tasks.txt
16-
{MNTPNT_PATH}/current/general/events.txt
17-
{MNTPNT_PATH}/current/other/finished_tasks.txt
18-
{MNTPNT_PATH}/records/internal/analysis.txt
19-
{MNTPNT_PATH}/records/internal/project.txt
20-
{MNTPNT_PATH}/records/external/statistics.txt
21-
{MNTPNT_PATH}/bookmarks/main.txt
22-
{MNTPNT_PATH}/bookmarks/news.txt
3+
{MNTPNT_PATH}/current/primary/my-goals.txt
4+
{MNTPNT_PATH}/current/primary/events.txt
5+
{MNTPNT_PATH}/current/save/finished_tasks.txt

file_management/file_retrieval/locatefile/database/file_paths/mount-drive-2-paths

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
{MNTPNT_PATH}/components/main/webapp/source1.html
55
{MNTPNT_PATH}/components/main/webapp/source2.html
66
{MNTPNT_PATH}/components/main/webapp/source1.js
7-
{MNTPNT_PATH}/components/main/configurations/default/main_config.sh
8-
{MNTPNT_PATH}/components/main/resources/logo.png
9-
{MNTPNT_PATH}/global/INFO
107
{MNTPNT_PATH}/global/utilities.jar
118
{MNTPNT_PATH}/global/resources/global_functions.sh
12-
{MNTPNT_PATH}/global/resources/parser.pl
9+
{MNTPNT_PATH}/global/resources/file-parser.pl

file_management/file_retrieval/locatefile/dbfilepaths

Lines changed: 27 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
# dbfilepaths
55
#
66
# Description:
7-
# The databases' file paths
7+
# The file paths to extract to the database
88
#
99
# Usage note:
1010
# A file or directory path for a database is specified using the "find_out"
11-
# function. It searches and returns files (or directories) recursively and
12-
# has the following parameters:
11+
# function. It has the following parameters:
1312
# 1. Type of file to output: "f" for files and "d" for directories
1413
# 2. Maximum depth to search (e.g. "0" for no depth [and to output just the
1514
# file itself] and "1" for the first level subdirectory)
@@ -31,46 +30,34 @@ for dbFileName in "${DATABASE_FILE_NAMES[@]}"; do
3130
dest="${FILE_PATHS_DATABASE_DIRECTORY}/${dbFileName}"
3231

3332
case "${dbFileName}" in
33+
'home-paths')
34+
echo -n '' > "${dest}"
35+
36+
# Add a single file.
37+
find_out f 0 "${dest}" '/home/user/documents/my-document.txt'
38+
# Add all files in a directory.
39+
find_out f 1 "${dest}" '/home/user/archives/backup'
40+
# Add all files in a directory and its subdirectories.
41+
find_out f 2 "${dest}" '/home/user/bin'
42+
;;
43+
3444
'mount-drive-1-paths')
3545
if mountpoint '/mnt/usb2' >/dev/null; then
3646
echo -n '' > "${dest}"
3747

38-
find_out 'f' '0' "${dest}" '/mnt/usb2/general/notes/assignment.txt'
39-
find_out 'f' '1' "${dest}" '/mnt/usb2/general'
40-
find_out 'f' '1' "${dest}" '/mnt/usb2/general/reference'
41-
find_out 'f' '0' "${dest}" '/mnt/usb2/other/finished_tasks.txt'
42-
find_out 'f' '1' "${dest}" '/mnt/usb2/finance'
43-
find_out 'f' '9' "${dest}" '/mnt/usb2/current' --nodot
44-
find_out 'f' '1' "${dest}" '/mnt/usb2/records/internal'
45-
find_out 'f' '1' "${dest}" '/mnt/usb2/records/external'
46-
find_out 'f' '1' "${dest}" '/mnt/usb2/bookmarks'
48+
find_out f 0 "${dest}" '/mnt/usb2/general/notes/my-notes.txt'
49+
find_out f 4 "${dest}" '/mnt/usb2/current' --nodot
4750
fi
4851
;;
4952

5053
'mount-drive-2-paths')
5154
if mountpoint '/mnt/usb3' >/dev/null; then
5255
echo -n '' > "${dest}"
5356

54-
find_out 'f' '5' "${dest}" '/mnt/usb3/components/main'
55-
find_out 'f' '0' "${dest}" '/mnt/usb3/components/configurations/default/main_config.sh'
56-
find_out 'f' '0' "${dest}" '/mnt/usb3/components/main/resources/logo.png'
57-
find_out 'f' '2' "${dest}" '/mnt/usb3/global'
57+
find_out f 5 "${dest}" '/mnt/usb3/components/main'
58+
find_out f 2 "${dest}" '/mnt/usb3/global'
5859
fi
5960
;;
60-
61-
'home-paths')
62-
echo -n '' > "${dest}"
63-
64-
find_out 'f' '1' "${dest}" '/home/user/documents'
65-
find_out 'f' '0' "${dest}" '/home/user/.bashrc'
66-
find_out 'f' '0' "${dest}" '/home/user/.bash_profile'
67-
find_out 'f' '0' "${dest}" '/home/user/.vimrc'
68-
find_out 'f' '0' "${dest}" '/home/user/.ssh/config'
69-
find_out 'f' '1' "${dest}" '/home/user/bin'
70-
find_out 'f' '0' "${dest}" '/home/user/share/calendar/events.txt'
71-
find_out 'f' '2' "${dest}" '/home/user/pictures'
72-
find_out 'f' '1' "${dest}" '/home/user/archived_data/backup'
73-
;;
7461
esac
7562
done
7663

@@ -83,31 +70,29 @@ for dbFileName in "${DATABASE_FILE_NAMES[@]}"; do
8370
'home-paths')
8471
echo -n '' > "${dest}"
8572

86-
find_out 'd' '0' "${dest}" '/home/user/documents'
87-
find_out 'd' '0' "${dest}" '/home/user/bin'
88-
find_out 'd' '0' "${dest}" '/home/user/share'
89-
find_out 'd' '0' "${dest}" '/home/user/pictures'
90-
find_out 'd' '0' "${dest}" '/home/user/archived_data'
73+
# Add a single directory.
74+
find_out d 0 "${dest}" '/home/user/documents'
75+
# Add all directories in a directory.
76+
find_out d 1 "${dest}" '/home/user/archives'
77+
# Add all directories in a directory and all second level directories.
78+
find_out d 2 "${dest}" '/home/user/bin'
9179
;;
9280

9381
'mount-drive-1-paths')
9482
if mountpoint '/mnt/usb2' >/dev/null; then
9583
echo -n '' > "${dest}"
9684

97-
find_out 'd' '1' "${dest}" '/mnt/usb2/general'
98-
find_out 'd' '1' "${dest}" '/mnt/usb2/current'
99-
find_out 'd' '1' "${dest}" '/mnt/usb2/records'
100-
find_out 'd' '0' "${dest}" '/mnt/usb2/bookmarks'
85+
find_out d 1 "${dest}" '/mnt/usb2/general'
86+
find_out d 1 "${dest}" '/mnt/usb2/current'
10187
fi
10288
;;
10389

10490
'mount-drive-2-paths')
10591
if mountpoint '/mnt/usb3' >/dev/null; then
10692
echo -n '' > "${dest}"
10793

108-
find_out 'd' '5' "${dest}" '/mnt/usb3/components/main'
109-
find_out 'd' '0' "${dest}" '/mnt/usb3/global'
110-
find_out 'd' '0' "${dest}" '/mnt/usb3/global/resources'
94+
find_out d 5 "${dest}" '/mnt/usb3/components/main'
95+
find_out d 1 "${dest}" '/mnt/usb3/global'
11196
fi
11297
;;
11398
esac

0 commit comments

Comments
 (0)