we can create links (hard links, symbolic links) now
added winix functions: ln winix function 'default' can be used without redirecting now added new tickets types: TypeProgress, TypeString, TypeMultistring, TypeImages, TypeFiles now tickets are combined with files added winix functions: showtickets fixed mountpoints: when the default root mount was created its parameter table was empty and it caused accessing to a non-existing objects fixed logger: modifiers (log1, log2, log3) were incorrectly treated added modifier: log4 (debug info) now we are moving threads to a new plugin 'thread' created directory: plugins/thread (not finished yet) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@704 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
111
functions/ln.cpp
Executable file
111
functions/ln.cpp
Executable file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2010, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ln.h"
|
||||
#include "core/misc.h"
|
||||
#include "functions/functions.h"
|
||||
|
||||
|
||||
|
||||
namespace Fun
|
||||
{
|
||||
|
||||
Ln::Ln()
|
||||
{
|
||||
fun.url = L"ln";
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Ln::HasAccess()
|
||||
{
|
||||
return system->HasWriteAccess(*request->dir_tab.back());
|
||||
}
|
||||
|
||||
|
||||
void Ln::CreateSymbolicLink(const std::wstring & link_to)
|
||||
{
|
||||
item.Clear(); // setting the date to now
|
||||
item.type = Item::symlink;
|
||||
item.parent_id = request->dir_tab.back()->id;
|
||||
item.url = request->PostVar(L"url");
|
||||
item.link_to = link_to;
|
||||
item.link_redirect = request->IsPostVar(L"makeredirect") ? 1 : 0;
|
||||
item.privileges = 0644; // !! tymczasowo, bedzie uzyte umask
|
||||
functions->SetUser(item);
|
||||
functions->PrepareUrl(item);
|
||||
|
||||
request->status = db->AddItem(item);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
log << log3 << "Ln: created a symbolic link to: " << link_to << logend;
|
||||
}
|
||||
|
||||
|
||||
void Ln::CreateHardLink(const std::wstring & link_to)
|
||||
{
|
||||
int res = system->FollowAllLinks(request->dir_tab, link_to, dir_tab, item, false, false);
|
||||
|
||||
if( res == 0 )
|
||||
{
|
||||
log << log2 << "Ln: " << link_to << " is a directory (can't create a hard link)" << logend;
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
}
|
||||
else
|
||||
if( res == 1 )
|
||||
{
|
||||
item.SetDateToNow();
|
||||
item.type = Item::file;
|
||||
item.parent_id = request->dir_tab.back()->id;
|
||||
item.url = request->PostVar(L"url");
|
||||
item.privileges = 0644; // !! tymczasowo, bedzie uzyte umask
|
||||
functions->SetUser(item);
|
||||
functions->PrepareUrl(item);
|
||||
request->status = db->AddHardLink(item);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
log << log3 << "Ln: created a hard link to: " << link_to << logend;
|
||||
}
|
||||
else
|
||||
if( res == 5 || res == 6 )
|
||||
{
|
||||
request->status = WINIX_ERR_PERMISSION_DENIED;
|
||||
}
|
||||
else
|
||||
{
|
||||
request->status = WINIX_ERR_NO_ITEM;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// we do not use notifications for links
|
||||
void Ln::MakePost()
|
||||
{
|
||||
link_to = request->PostVar(L"linkto");
|
||||
TrimWhite(link_to);
|
||||
|
||||
if( link_to.empty() )
|
||||
return;
|
||||
|
||||
int type = Toi(request->PostVar(L"linktype"));
|
||||
|
||||
if( type == 0 )
|
||||
CreateHardLink(link_to);
|
||||
else
|
||||
CreateSymbolicLink(link_to);
|
||||
|
||||
if( request->status == WINIX_ERR_OK )
|
||||
system->RedirectTo(item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user