exists

How to check if a file exists and is readable in C++?

匿名 (未验证) 提交于 2019-12-03 02:14:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've got a fstream my_file("test.txt"), but I don't know if test.txt exists. In case it exists, I would like to know if I can read it, too. How to do that? I use Linux. 回答1: I would probably go with: ifstream my_file("test.txt"); if (my_file.good()) { // read away } The good method checks if the stream is ready to be read from. 回答2: You might use Boost.Filesystem . It has a boost::filesystem::exist function. I don't know how about checking read access rights. You could look in Boost.Filesystem too. However likely there will be no other

Symfony2 - checking if file exists

匿名 (未验证) 提交于 2019-12-03 02:14:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a loop in Twig template, which returns multiple values. Most important - an ID of my entry. When I didn't use any framework nor template engine, I used simply file_exists() within the loop. Now, I can't seem to find a way to do it in Twig. When I display user's avatar in header, I use file_exists() in controller, but I do it because I don't have a loop. I tried defined in Twig, but it doesn't help me. Any ideas? 回答1: If you want want to check the existence of a file which is not a twig template (so defined can't work), create a

(十一)DVWA全等级SQL Injection(Blind)盲注--手工测试过程解析

故事扮演 提交于 2019-12-03 02:13:30
一、DVWA-SQL Injection(Blind)测试分析 SQL盲注 VS 普通SQL注入 : 普通SQL注入 SQL盲注 1.执行SQL注入攻击时,服务器会响应来自数据库服务器的错误信息,信息提示SQL语法不正确等 2.一般在页面上直接就会显示执行sql语句的结果 1.一般情况,执行SQL盲注,服务器不会直接返回具体的数据库错误or语法错误,而是会返回程序开发所设置的特定信息(也有特例,如基于报错的盲注) 2.一般在页面上不会直接显示sql执行的结果 3.有可能出现不确定sql是否执行的情况 根据页面不同的响应方式,SQL盲注分为:基于布尔的盲注、基于时间的盲注、基于报错的盲注。 SQL盲注-测试思路 对于 基于布尔的盲注 ,可通过构造真or假判断条件(数据库各项信息取值的大小比较,如:字段长度、版本数值、字段名、字段名各组成部分在不同位置对应的字符ASCII码...),将构造的sql语句提交到服务器,然后根据服务器对不同的请求返回不同的页面结果(True、False);然后不断调整判断条件中的数值以逼近真实值,特别是需要关注响应从True<-->False发生变化的转折点。 对于 基于时间的盲注 ,通过构造真or假判断条件的sql语句,且sql语句中根据需要联合使用sleep()函数一同向服务器发送请求,观察服务器响应结果是否会执行所设置时间的延迟响应

“tag already exists in the remote\&quot; error after recreating the git tag

匿名 (未验证) 提交于 2019-12-03 02:13:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I get the following error after I run the steps below: To git@provider.com:username/repo-name.git ! [rejected] dev -> dev (already exists) error: failed to push some refs to 'git@provider.com:username/repo-name.git' hint: Updates were rejected because the tag already exists in the remote. Created the repository Cloned the repo on the local machine. Modified the README file, commited the changes and pushed the commit. Created tag dev : git tag dev Pushed tags: git push --tags Modified the README file, commited the changes and pushed the

mysql ALTER TABLE if column not exists

匿名 (未验证) 提交于 2019-12-03 02:13:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have this code: ALTER TABLE `settings` ADD COLUMN `multi_user` TINYINT(1) NOT NULL DEFAULT 1 And I want to alter this table only if this column doesnt exist. I'm trying a lot of differents ways, but nothing works: ALTER TABLE `settings` ADD COLUMN IF NOT EXISTS `multi_user` TINYINT(1) NOT NULL DEFAULT 1 With procedure: DELIMITER $$ CREATE PROCEDURE Alter_Table() BEGIN DECLARE _count INT; SET _count = ( SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'settings' AND COLUMN_NAME = 'multi_user'); IF _count = 0 THEN ALTER

angularjs: custom directive to check if a username exists

匿名 (未验证) 提交于 2019-12-03 02:12:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have my registration form with textbox username. I want to do is when the user enter the username, the custom directive will check if the entered username is exists in the database. directives.js angular . module ( 'installApp' ). directive ( 'pwCheck' , function ( $http ) { return { require : 'ngModel' , link : function ( scope , elem , attrs , ctrl ) { elem . on ( 'blur' , function ( evt ) { scope . $apply ( function () { $http ({ method : 'GET' , url : '../api/v1/users' , data : { username : elem . val (), dbField : attrs .

How to check if a stored procedure exists before creating it

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a SQL script that has to be run every time a client executes the "database management" functionality. The script includes creating stored procedures on the client database. Some of these clients might already have the stored procedure upon running the script, and some may not. I need to have the missing stored procedures added to the client database, but it doesn't matter how much I try to bend T-SQL syntax, I get CREATE/ALTER PROCEDURE' must be the first statement in a query batch I've read that dropping before creating works, but I

Linq .Any VS .Exists - What&#039;s the difference?

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Using Linq on collections, what is the difference between the following lines of code? if(!coll.Any(i => i.Value)) and if(!coll.Exists(i => i.Value)) Update 1 When I disassemble .Exists it looks like there is no code. Update 2 Anyone know why there is not code there for this one? 回答1: See documentation List.Exists (Object method - MSDN) Determines whether the List(T) contains elements that match the conditions defined by the specified predicate. This exists since .NET 2.0, so before LINQ. Meant to be used with the Predicate delegate , but

Laravel check if related model exists

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an Eloquent model which has a related model: public function option() { return $this->hasOne('RepairOption', 'repair_item_id'); } public function setOptionArrayAttribute($values) { $this->option->update($values); } when I create the model, it does not necessarily have a related model. When I update it, I might add an option, or not. So I need to check if the related model exists, to either update it, or create it, respectively: $model = RepairItem::find($id); if (Input::has('option')) { if (<related_model_exists>) { $option = new

How to symlink a file in Linux?

匿名 (未验证) 提交于 2019-12-03 02:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to make a symbolic link in Linux. I have written this bash command where the first path is the folder I want link into and the second path is the compiled source. ln -s '+basebuild+'/IpDome-kernel/kernel /home/build/sandbox/gen2/basebuild/IpDome-kernel/kernal Is this correct? 回答1: To create a new symlink (will fail if symlink exists already): ln -s /path/to/file /path/to/symlink To create or update a symlink: ln -sf /path/to/file /path/to/symlink 回答2: ln -s TARGET LINK_NAME Where the -s makes it symbolic. 回答3: ln -s EXISTING_FILE_OR