Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
ae64a7d3
Commit
ae64a7d3
authored
1 year ago
by
juanf
Browse files
Options
Downloads
Patches
Plain Diff
SSDM-13521: Providing same test coverage for new Posix class as for Unix class
parent
be85819e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!40
SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib-commonbase/source/java/ch/systemsx/cisd/common/io/Posix.java
+39
-6
39 additions, 6 deletions
...monbase/source/java/ch/systemsx/cisd/common/io/Posix.java
with
39 additions
and
6 deletions
lib-commonbase/source/java/ch/systemsx/cisd/common/io/Posix.java
+
39
−
6
View file @
ae64a7d3
...
...
@@ -187,6 +187,10 @@ public final class Posix
return
getGid
();
}
/**
* Sets the owner of <var>fileName</var> to the specified <var>uid</var> and <var>gid</var> values.
* Dereferences a symbolic link.
*/
public
static
void
setOwner
(
String
path
,
int
userId
,
int
groupId
)
{
try
...
...
@@ -567,6 +571,11 @@ public final class Posix
return
symbolicLinkOrNull
!=
null
;
}
/**
* Returns the number of hard links for the <var>linkName</var>. Does not dereference a symbolic link.
*
* @throws IOExceptionUnchecked If the information could not be obtained, e.g. because the link does not exist.
*/
public
int
getNumberOfHardLinks
()
throws
IOException
{
Number
count
=
(
Number
)
Files
.
getAttribute
(
path
,
"unix:nlink"
,
LinkOption
.
NOFOLLOW_LINKS
);
...
...
@@ -656,6 +665,12 @@ public final class Posix
return
getLinkInfo
(
absolutePath
,
true
);
}
/**
* Returns the information about <var>linkName</var>. If <code>readSymbolicLinkTarget == true</code>, then the symbolic link target is read when
* <var>linkName</var> is a symbolic link.
*
* @throws IOExceptionUnchecked If the information could not be obtained, e.g. because the link does not exist.
*/
public
static
Stat
getLinkInfo
(
String
pathAsString
,
boolean
readSymbolicLinkTarget
)
{
try
{
...
...
@@ -722,20 +737,38 @@ public final class Posix
}
}
/**
* Returns the information about <var>linkName</var>, or {@link NullPointerException}, if the information could not be obtained, e.g. because the
* link does not exist.
*/
public
static
Stat
tryGetLinkInfo
(
String
pathAsString
){
return
getLinkInfo
(
pathAsString
,
true
);
}
/**
* Returns the information about <var>fileName</var>, or {@link NullPointerException}, if the information could not be obtained, e.g. because the
* file does not exist.
*/
public
static
Stat
tryGetFileInfo
(
String
absolutePath
)
{
return
getFileInfo
(
absolutePath
,
true
);
}
/**
* Returns the information about <var>fileName</var>.
*
* @throws IOExceptionUnchecked If the information could not be obtained, e.g. because the file does not exist.
*/
public
static
Stat
getFileInfo
(
String
pathAsString
)
{
return
getFileInfo
(
pathAsString
,
true
);
}
/**
* Returns the information about <var>fileName</var>.
*
* @throws IOExceptionUnchecked If the information could not be obtained, e.g. because the file does not exist.
*/
public
static
Stat
getFileInfo
(
String
pathAsString
,
boolean
readSymbolicLinkTarget
)
throws
IOExceptionUnchecked
{
...
...
@@ -799,13 +832,13 @@ public final class Posix
}
}
/**
* Sets the access mode of <var>filename</var> to the specified <var>mode</var> value.
* Dereferences a symbolic link.
*/
public
static
void
setAccessMode
(
String
path
,
short
mode
)
throws
IOExceptionUnchecked
{
try
{
Set
<
PosixFilePermission
>
permissions
=
getFilePermissionsMode
(
mode
);
Files
.
setPosixFilePermissions
(
Path
.
of
(
path
),
permissions
);
}
catch
(
IOException
e
)
{
throw
new
IOExceptionUnchecked
(
e
);
}
Set
<
PosixFilePermission
>
permissions
=
getFilePermissionsMode
(
mode
);
setAccessMode
(
path
,
permissions
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment