Skip to content

Commit

Permalink
Fix file open constants
Browse files Browse the repository at this point in the history
  • Loading branch information
quelgar committed Feb 1, 2024
1 parent b17c7c2 commit d7fa6e6
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 40 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ src/test/resources/write-test.txt
/.metals
.vscode
metals.sbt
/.scala-build
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 1.9.7
sbt.version = 1.9.8
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.16")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.17")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.10.0")
99 changes: 83 additions & 16 deletions src/main/resources/scala-native/helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,47 +80,114 @@ void scala_uv_init_sockaddr_in6(const char *address, int port, unsigned int flow
addr->sin6_scope_id = htonl(scope_id);
}

int scala_uv_value_o_rdonly()
// File open constants

int scala_uv_value_o_append()
{
return O_RDONLY;
return UV_FS_O_APPEND;
}

int scala_uv_value_o_wronly()
int scala_uv_value_o_creat()
{
return O_WRONLY;
return UV_FS_O_CREAT;
}

int scala_uv_value_o_rdwr()
int scala_uv_value_o_direct()
{
return O_RDWR;
return UV_FS_O_DIRECT;
}

int scala_uv_value_o_creat()
int scala_uv_value_o_directory()
{
return O_CREAT;
return UV_FS_O_DIRECTORY;
}

int scala_uv_value_o_dsync()
{
return UV_FS_O_DSYNC;
}

int scala_uv_value_o_excl()
{
return O_EXCL;
return UV_FS_O_EXCL;
}

int scala_uv_value_o_trunc()
int scala_uv_value_o_exlock()
{
return O_TRUNC;
return UV_FS_O_EXLOCK;
}

int scala_uv_value_o_append()
int scala_uv_value_o_filemap()
{
return O_APPEND;
return UV_FS_O_FILEMAP;
}

int scala_uv_value_o_dsync()
int scala_uv_value_o_noatime()
{
return UV_FS_O_NOATIME;
}

int scala_uv_value_o_noctty()
{
return UV_FS_O_NOCTTY;
}

int scala_uv_value_o_nofollow()
{
return UV_FS_O_NOFOLLOW;
}

int scala_uv_value_o_nonblock()
{
return UV_FS_O_NONBLOCK;
}

int scala_uv_value_o_random()
{
return UV_FS_O_RANDOM;
}

int scala_uv_value_o_rdonly()
{
return UV_FS_O_RDONLY;
}

int scala_uv_value_o_rdwr()
{
return O_DSYNC;
return UV_FS_O_RDWR;
}

int scala_uv_value_o_sequential()
{
return UV_FS_O_SEQUENTIAL;
}

int scala_uv_value_o_short_lived()
{
return UV_FS_O_SHORT_LIVED;
}

int scala_uv_value_o_symlink()
{
return UV_FS_O_SYMLINK;
}

int scala_uv_value_o_sync()
{
return O_SYNC;
return UV_FS_O_SYNC;
}

int scala_uv_value_o_temporary()
{
return UV_FS_O_TEMPORARY;
}

int scala_uv_value_o_trunc()
{
return UV_FS_O_TRUNC;
}

int scala_uv_value_o_wronly()
{
return UV_FS_O_WRONLY;
}
7 changes: 0 additions & 7 deletions src/main/resources/scala-native/platform_specific.c

This file was deleted.

27 changes: 19 additions & 8 deletions src/main/scala/scalauv/UvConstants.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,28 @@ object RunMode {
}

object FileOpenFlags {
val O_RDONLY = helpers.scala_uv_value_o_rdonly()
val O_WRONLY = helpers.scala_uv_value_o_wronly()
val O_RDWR = helpers.scala_uv_value_o_rdwr()

val O_CREAT = helpers.scala_uv_value_o_creat()
val O_EXCL = helpers.scala_uv_value_o_excl()
val O_TRUNC = helpers.scala_uv_value_o_trunc()

val O_APPEND = helpers.scala_uv_value_o_append()
val O_CREAT = helpers.scala_uv_value_o_creat()
val O_DIRECT = helpers.scala_uv_value_o_direct()
val O_DIRECTORY = helpers.scala_uv_value_o_directory()
val O_DSYNC = helpers.scala_uv_value_o_dsync()
val O_EXCL = helpers.scala_uv_value_o_excl()
val O_EXLOCK = helpers.scala_uv_value_o_exlock()
val O_FILEMAP = helpers.scala_uv_value_o_filemap()
val O_NOATIME = helpers.scala_uv_value_o_noatime()
val O_NOCTTY = helpers.scala_uv_value_o_noctty()
val O_NOFOLLOW = helpers.scala_uv_value_o_nofollow()
val O_NONBLOCK = helpers.scala_uv_value_o_nonblock()
val O_RANDOM = helpers.scala_uv_value_o_random()
val O_RDONLY = helpers.scala_uv_value_o_rdonly()
val O_RDWR = helpers.scala_uv_value_o_rdwr()
val O_SEQUENTIAL = helpers.scala_uv_value_o_sequential()
val O_SHORT_LIVED = helpers.scala_uv_value_o_short_lived()
val O_SYMLINK = helpers.scala_uv_value_o_symlink()
val O_SYNC = helpers.scala_uv_value_o_sync()
val O_TEMPORARY = helpers.scala_uv_value_o_temporary()
val O_TRUNC = helpers.scala_uv_value_o_trunc()
val O_WRONLY = helpers.scala_uv_value_o_wronly()
}

object CreateMode {
Expand Down
41 changes: 34 additions & 7 deletions src/main/scala/scalauv/helpers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,48 @@ private[scalauv] object helpers {
): Unit =
extern

def scala_uv_value_o_rdonly(): CInt = extern
def scala_uv_value_o_append(): CInt = extern

def scala_uv_value_o_wronly(): CInt = extern
def scala_uv_value_o_creat(): CInt = extern

def scala_uv_value_o_rdwr(): CInt = extern
def scala_uv_value_o_direct(): CInt = extern

def scala_uv_value_o_creat(): CInt = extern
def scala_uv_value_o_directory(): CInt = extern

def scala_uv_value_o_dsync(): CInt = extern

def scala_uv_value_o_excl(): CInt = extern

def scala_uv_value_o_trunc(): CInt = extern
def scala_uv_value_o_exlock(): CInt = extern

def scala_uv_value_o_append(): CInt = extern
def scala_uv_value_o_filemap(): CInt = extern

def scala_uv_value_o_dsync(): CInt = extern
def scala_uv_value_o_noatime(): CInt = extern

def scala_uv_value_o_noctty(): CInt = extern

def scala_uv_value_o_nofollow(): CInt = extern

def scala_uv_value_o_nonblock(): CInt = extern

def scala_uv_value_o_random(): CInt = extern

def scala_uv_value_o_rdonly(): CInt = extern

def scala_uv_value_o_rdwr(): CInt = extern

def scala_uv_value_o_sequential(): CInt = extern

def scala_uv_value_o_short_lived(): CInt = extern

def scala_uv_value_o_symlink(): CInt = extern

def scala_uv_value_o_sync(): CInt = extern

def scala_uv_value_o_temporary(): CInt = extern

def scala_uv_value_o_trunc(): CInt = extern

def scala_uv_value_o_wronly(): CInt = extern

}

0 comments on commit d7fa6e6

Please sign in to comment.