Skip to content

Commit

Permalink
Merge pull request #32 from TrurlMcByte/master
Browse files Browse the repository at this point in the history
generate nessesary subfolders in play_local_path
  • Loading branch information
Sergey committed Aug 7, 2015
2 parents 335bf07 + 38f98aa commit b1e28ea
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ngx_rtmp_play_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,9 @@ ngx_rtmp_play_copy_local_file(ngx_rtmp_session_t *s, u_char *name)
ngx_rtmp_play_ctx_t *ctx;
u_char *path, *p;
static u_char dpath[NGX_MAX_PATH + 1];
u_char *d;
static u_char dir[NGX_MAX_PATH + 1];
u_int l;

pacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_play_module);
if (pacf == NULL) {
Expand All @@ -500,6 +503,26 @@ ngx_rtmp_play_copy_local_file(ngx_rtmp_session_t *s, u_char *name)

p = ngx_snprintf(dpath, NGX_MAX_PATH, "%V/%s%V", &pacf->local_path,
name + ctx->pfx_size, &ctx->sfx);

d = name + ctx->pfx_size;
while (*d != '\0') {
if (*d == '/') {
p = ngx_snprintf(dir, NGX_MAX_PATH, "%V/%s", &pacf->local_path, name + ctx->pfx_size, &ctx->sfx);
l = ngx_strlen(dir) - ngx_strlen(d);
dir[l]='\0';
ngx_log_debug2(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"play: create dir '%s' for '%s'", dir, dpath);
if (ngx_create_dir(dir, 0700) == NGX_FILE_ERROR) {
if (ngx_errno != NGX_EEXIST) {
ngx_log_error(NGX_LOG_ERR, s->connection->log, ngx_errno,
"play: error creating dir '%s' for '%s'", dir, dpath);
break;
}
}
}
d++;
}

*p = 0;

ngx_log_debug2(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
Expand Down

0 comments on commit b1e28ea

Please sign in to comment.