FreeBSD does not need the file descriptor for device.

This commit is contained in:
2020-11-03 19:23:07 +00:00
parent f271cd1942
commit 7b2529ebb9
2 changed files with 0 additions and 15 deletions

View File

@@ -35,23 +35,12 @@ void* DeviceOpen(const char* device_path)
memset(ctx, 0, sizeof(DeviceContext));
ctx->fd = open(device_path, O_RDWR | O_NONBLOCK | O_CREAT);
if((ctx->fd < 0) && (errno == EACCES || errno == EROFS)) ctx->fd = open(device_path, O_RDONLY | O_NONBLOCK);
if(ctx->fd <= 0)
{
free(ctx);
return NULL;
}
strncpy(ctx->device_path, device_path, 4096);
ctx->device = cam_open_device(ctx->device_path, O_RDWR);
if(!ctx->device)
{
close(ctx->fd);
free(ctx);
return NULL;
}
@@ -67,8 +56,6 @@ void DeviceClose(void* device_ctx)
if(ctx->device) cam_close_device(ctx->device);
close(ctx->fd);
free(ctx);
}

View File

@@ -24,11 +24,9 @@
#endif
#include <camlib.h>
#include <stdio.h>
typedef struct
{
int fd;
char device_path[4096];
struct cam_device* device;
} DeviceContext;