Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
gozfree committed Dec 22, 2018
1 parent 9cba33c commit 0985222
Show file tree
Hide file tree
Showing 39 changed files with 88 additions and 280 deletions.
25 changes: 0 additions & 25 deletions Changelog

This file was deleted.

1 change: 0 additions & 1 deletion android_jni_libs/jni/libconifg

This file was deleted.

1 change: 0 additions & 1 deletion android_jni_libs/jni/libdict

This file was deleted.

1 change: 0 additions & 1 deletion android_jni_libs/jni/libgevent

This file was deleted.

1 change: 0 additions & 1 deletion android_jni_libs/jni/liblog

This file was deleted.

1 change: 0 additions & 1 deletion android_jni_libs/jni/libmp4parser

This file was deleted.

1 change: 0 additions & 1 deletion android_jni_libs/jni/libp2p

This file was deleted.

1 change: 0 additions & 1 deletion android_jni_libs/jni/libptcp

This file was deleted.

1 change: 0 additions & 1 deletion android_jni_libs/jni/librbtree

This file was deleted.

1 change: 0 additions & 1 deletion android_jni_libs/jni/librpc

This file was deleted.

1 change: 0 additions & 1 deletion android_jni_libs/jni/libskt

This file was deleted.

1 change: 0 additions & 1 deletion android_jni_libs/jni/libsort

This file was deleted.

1 change: 0 additions & 1 deletion android_jni_libs/jni/libstun

This file was deleted.

1 change: 0 additions & 1 deletion android_jni_libs/jni/libworkq

This file was deleted.

2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ PLATFORM="[linux|pi|android|ios]"
#basic libraries
BASIC_LIBS="libmacro libatomic libtime liblog libgevent libworkq libdict libsort \
librbtree libringbuffer liblock libthread libconfig libvector libbase64 \
libdebug libfile libuvc libmp4parser libfilewatcher libqueue "
libdebug libfile libuvc libmp4parser libqueue "
FRAMEWORK_LIBS="libipc"
NETWORK_LIBS="libskt libstun libptcp librpc libp2p librtsp"

Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions build/android_jni_libs/jni/libconfig
1 change: 1 addition & 0 deletions build/android_jni_libs/jni/libdict
1 change: 1 addition & 0 deletions build/android_jni_libs/jni/libgevent
1 change: 1 addition & 0 deletions build/android_jni_libs/jni/liblog
1 change: 1 addition & 0 deletions build/android_jni_libs/jni/libmacro
1 change: 1 addition & 0 deletions build/android_jni_libs/jni/libmp4parser
1 change: 1 addition & 0 deletions build/android_jni_libs/jni/librbtree
1 change: 1 addition & 0 deletions build/android_jni_libs/jni/librpc
1 change: 1 addition & 0 deletions build/android_jni_libs/jni/libskt
1 change: 1 addition & 0 deletions build/android_jni_libs/jni/libsort
1 change: 1 addition & 0 deletions build/android_jni_libs/jni/libworkq
File renamed without changes.
21 changes: 13 additions & 8 deletions libfile/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
###############################################################################
# Copyright (C) 2014-2015
# file: Makefile
# author: gozfree <[email protected]>
# created: 2016-07-22 14:17:17
# updated: 2016-07-22 14:17:17
###############################################################################

###############################################################################
# common
###############################################################################
Expand Down Expand Up @@ -40,17 +32,24 @@ endif
###############################################################################
# target and object
###############################################################################
ENABLE_FILEWATCHER = 1
LIBNAME = libfile
VERSION_SH = $(shell pwd)/version.sh $(LIBNAME)
VER = $(shell $(VERSION_SH); awk '/define\ $(LIBNAME)_version/{print $$3}' version.h)
TGT_LIB_H = $(LIBNAME).h
ifeq ($(ENABLE_FILEWATCHER), 1)
TGT_LIB_H += libfilewatcher.h
endif
TGT_LIB_A = $(LIBNAME).a
TGT_LIB_SO = $(LIBNAME).so
TGT_LIB_SO_VER = $(TGT_LIB_SO).${VER}
TGT_UNIT_TEST = test_$(LIBNAME)

OBJS_LIB = $(LIBNAME).o
OBJS_LIB += io.o fio.o
ifeq ($(ENABLE_FILEWATCHER), 1)
OBJS_LIB += filewatcher.o
endif
OBJS_UNIT_TEST = test_$(LIBNAME).o

###############################################################################
Expand All @@ -59,11 +58,17 @@ OBJS_UNIT_TEST = test_$(LIBNAME).o
CFLAGS := -g -Wall -Werror -fPIC
CFLAGS += $($(ARCH)_CFLAGS)
CFLAGS += -I$(OUTPUT)/include
ifeq ($(ENABLE_FILEWATCHER), 1)
CFLAGS += -DENABLE_FILEWATCHER
endif

SHARED := -shared

LDFLAGS := $($(ARCH)_LDFLAGS)
LDFLAGS += -pthread
ifeq ($(ENABLE_FILEWATCHER), 1)
LDFLAGS += -ldict -lgevent
endif

###############################################################################
# target
Expand Down
1 change: 1 addition & 0 deletions libfile/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
## libfile
This is a simple libfile library.

support io/fio and inotify
4 changes: 2 additions & 2 deletions libfilewatcher/libfilewatcher.c → libfile/filewatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
* License along with libraries; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
******************************************************************************/
#include <libmacro.h>
#include "libfilewatcher.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/inotify.h>
#include <libmacro.h>
#include "libfilewatcher.h"

#define WATCH_MOVED 1
#define WATCH_MODIFY 1
Expand Down
File renamed without changes.
62 changes: 60 additions & 2 deletions libfile/test_libfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
* License along with libraries; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
******************************************************************************/

#include "libfile.h"
#ifdef ENABLE_FILEWATCHER
#include "libfilewatcher.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -101,6 +103,60 @@ static void foo5(void)
printf("info->time_access = %" PRIu64 "\n", info.access_sec);
}

#ifdef ENABLE_FILEWATCHER
#define ROOT_DIR "./"
static struct fw *_fw = NULL;


void on_change(struct fw *fw, enum fw_type type, char *path)
{
switch (type) {
case FW_CREATE_DIR:
printf("[CREATE DIR] %s\n", path);
break;
case FW_CREATE_FILE:
printf("[CREATE FILE] %s\n", path);
break;
case FW_DELETE_DIR:
printf("[DELETE DIR] %s\n", path);
break;
case FW_DELETE_FILE:
printf("[DELETE FILE] %s\n", path);
break;
case FW_MOVE_FROM_DIR:
printf("[MOVE FROM DIR] %s\n", path);
break;
case FW_MOVE_TO_DIR:
printf("[MOVE TO DIR] %s\n", path);
break;
case FW_MOVE_FROM_FILE:
printf("[MOVE FROM FILE] %s\n", path);
break;
case FW_MOVE_TO_FILE:
printf("[MOVE TO FILE] %s\n", path);
break;
case FW_MODIFY_FILE:
printf("[MODIFY FILE] %s\n", path);
break;
default:
break;
}
}


int file_watcher_foo()
{
_fw = fw_init(on_change);
if (!_fw) {
printf("fw_init failed!\n");
return -1;
}
fw_add_watch_recursive(_fw, ROOT_DIR);
fw_dispatch(_fw);
return 0;
}
#endif

int main(int argc, char **argv)
{
uint64_t size = 1000;
Expand All @@ -116,6 +172,8 @@ int main(int argc, char **argv)
if (0 != file_create("jjj.c")) {
printf("file_create failed!\n");
}
#ifdef ENABLE_FILEWATCHER
file_watcher_foo();
#endif
return 0;
}

14 changes: 0 additions & 14 deletions libfilewatcher/Android.mk

This file was deleted.

104 changes: 0 additions & 104 deletions libfilewatcher/Makefile

This file was deleted.

3 changes: 0 additions & 3 deletions libfilewatcher/README.md

This file was deleted.

Loading

0 comments on commit 0985222

Please sign in to comment.